Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/HashSet.h |
| diff --git a/third_party/WebKit/Source/wtf/HashSet.h b/third_party/WebKit/Source/wtf/HashSet.h |
| index afd943b3f2936dd10fa69eb8ace109c58fb32f30..865f0da2517f867e11a681918c0cd7db7c6ac228 100644 |
| --- a/third_party/WebKit/Source/wtf/HashSet.h |
| +++ b/third_party/WebKit/Source/wtf/HashSet.h |
| @@ -23,6 +23,7 @@ |
| #include "wtf/HashTable.h" |
| #include "wtf/allocator/PartitionAllocator.h" |
| +#include <initializer_list> |
| namespace WTF { |
| @@ -55,6 +56,15 @@ public: |
| typedef HashTableConstIteratorAdapter<HashTableType, ValueTraits> const_iterator; |
| typedef typename HashTableType::AddResult AddResult; |
| + HashSet() = default; |
| + HashSet(const HashSet&) = default; |
| + HashSet& operator=(const HashSet&) = default; |
| + HashSet(HashSet&&) = default; |
| + HashSet& operator=(HashSet&&) = default; |
| + |
| + HashSet(std::initializer_list<ValueType> elements); |
| + HashSet& operator=(std::initializer_list<ValueType> elements); |
| + |
| void swap(HashSet& ref) |
| { |
| m_impl.swap(ref.m_impl); |
| @@ -131,6 +141,22 @@ struct HashSetTranslatorAdapter { |
| } |
| }; |
| +template <typename Value, typename HashFunctions, typename Traits, typename Allocator> |
| +HashSet<Value, HashFunctions, Traits, Allocator>::HashSet(std::initializer_list<ValueType> elements) |
| +{ |
|
tzik
2016/05/19 08:59:57
Can we reserveCapacity here?
Yuta Kitamura
2016/05/19 09:04:21
Done.
|
| + for (const auto& element : elements) |
| + add(element); |
| +} |
| + |
| +template <typename Value, typename HashFunctions, typename Traits, typename Allocator> |
| +auto HashSet<Value, HashFunctions, Traits, Allocator>::operator=(std::initializer_list<ValueType> elements) -> HashSet& |
| +{ |
| + clear(); |
| + for (const auto& element : elements) |
| + add(element); |
| + return *this; |
| +} |
| + |
| template <typename T, typename U, typename V, typename W> |
| inline unsigned HashSet<T, U, V, W>::size() const |
| { |