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..d68d2669a4076ed4c84f732dfdec336ced11ac6e 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,26 @@ struct HashSetTranslatorAdapter { |
| } |
| }; |
| +template <typename Value, typename HashFunctions, typename Traits, typename Allocator> |
| +HashSet<Value, HashFunctions, Traits, Allocator>::HashSet(std::initializer_list<ValueType> elements) |
| +{ |
| + if (elements.size()) |
| + m_impl.reserveCapacityForSize(elements.size()); |
| + for (const ValueType& 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(); |
|
sof
2016/05/19 09:21:26
Would
HashSet set(elements);
*this = std::mov
Yuta Kitamura
2016/05/19 09:41:57
Yeah, that's better. I'm fixing.
|
| + if (elements.size()) |
| + m_impl.reserveCapacityForSize(elements.size()); |
| + for (const ValueType& element : elements) |
| + add(element); |
| + return *this; |
| +} |
| + |
| template <typename T, typename U, typename V, typename W> |
| inline unsigned HashSet<T, U, V, W>::size() const |
| { |