Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: third_party/WebKit/Source/wtf/ListHashSet.h

Issue 2688893002: Migrate WTF::HashSet::add() to ::insert() [continued] (Closed)
Patch Set: rebase, fix one platform-specific reference Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/LinkedHashSet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> 4 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 iterator find(const T&); 182 iterator find(const T&);
183 template <typename HashTranslator, typename T> 183 template <typename HashTranslator, typename T>
184 const_iterator find(const T&) const; 184 const_iterator find(const T&) const;
185 template <typename HashTranslator, typename T> 185 template <typename HashTranslator, typename T>
186 bool contains(const T&) const; 186 bool contains(const T&) const;
187 187
188 // The return value of add is a pair of a pointer to the stored value, and a 188 // The return value of add is a pair of a pointer to the stored value, and a
189 // bool that is true if an new entry was added. 189 // bool that is true if an new entry was added.
190 template <typename IncomingValueType> 190 template <typename IncomingValueType>
191 AddResult add(IncomingValueType&&); 191 AddResult add(IncomingValueType&&);
192 template <typename IncomingValueType>
193 AddResult insert(IncomingValueType&&);
192 194
193 // Same as add() except that the return value is an iterator. Useful in 195 // Same as add() except that the return value is an iterator. Useful in
194 // cases where it's needed to have the same return value as find() and where 196 // cases where it's needed to have the same return value as find() and where
195 // it's not possible to use a pointer to the storedValue. 197 // it's not possible to use a pointer to the storedValue.
196 template <typename IncomingValueType> 198 template <typename IncomingValueType>
197 iterator addReturnIterator(IncomingValueType&&); 199 iterator addReturnIterator(IncomingValueType&&);
198 200
199 // Add the value to the end of the collection. If the value was already in 201 // Add the value to the end of the collection. If the value was already in
200 // the list, it is moved to the end. 202 // the list, it is moved to the end.
201 template <typename IncomingValueType> 203 template <typename IncomingValueType>
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 // actually changes when it does allocations. 926 // actually changes when it does allocations.
925 auto result = m_impl.template add<BaseTranslator>( 927 auto result = m_impl.template add<BaseTranslator>(
926 std::forward<IncomingValueType>(value), *this->getAllocator()); 928 std::forward<IncomingValueType>(value), *this->getAllocator());
927 if (result.isNewEntry) 929 if (result.isNewEntry)
928 appendNode(*result.storedValue); 930 appendNode(*result.storedValue);
929 return AddResult(*result.storedValue, result.isNewEntry); 931 return AddResult(*result.storedValue, result.isNewEntry);
930 } 932 }
931 933
932 template <typename T, size_t inlineCapacity, typename U, typename V> 934 template <typename T, size_t inlineCapacity, typename U, typename V>
933 template <typename IncomingValueType> 935 template <typename IncomingValueType>
936 typename ListHashSet<T, inlineCapacity, U, V>::AddResult
937 ListHashSet<T, inlineCapacity, U, V>::insert(IncomingValueType&& value) {
938 return add(value);
939 }
940
941 template <typename T, size_t inlineCapacity, typename U, typename V>
942 template <typename IncomingValueType>
934 typename ListHashSet<T, inlineCapacity, U, V>::iterator 943 typename ListHashSet<T, inlineCapacity, U, V>::iterator
935 ListHashSet<T, inlineCapacity, U, V>::addReturnIterator( 944 ListHashSet<T, inlineCapacity, U, V>::addReturnIterator(
936 IncomingValueType&& value) { 945 IncomingValueType&& value) {
937 return makeIterator(add(std::forward<IncomingValueType>(value)).m_node); 946 return makeIterator(add(std::forward<IncomingValueType>(value)).m_node);
938 } 947 }
939 948
940 template <typename T, size_t inlineCapacity, typename U, typename V> 949 template <typename T, size_t inlineCapacity, typename U, typename V>
941 template <typename IncomingValueType> 950 template <typename IncomingValueType>
942 typename ListHashSet<T, inlineCapacity, U, V>::AddResult 951 typename ListHashSet<T, inlineCapacity, U, V>::AddResult
943 ListHashSet<T, inlineCapacity, U, V>::appendOrMoveToLast( 952 ListHashSet<T, inlineCapacity, U, V>::appendOrMoveToLast(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 // through the HashTable. That includes m_head and m_tail so we do not have 1135 // through the HashTable. That includes m_head and m_tail so we do not have
1127 // to explicitly trace them here. 1136 // to explicitly trace them here.
1128 m_impl.trace(visitor); 1137 m_impl.trace(visitor);
1129 } 1138 }
1130 1139
1131 } // namespace WTF 1140 } // namespace WTF
1132 1141
1133 using WTF::ListHashSet; 1142 using WTF::ListHashSet;
1134 1143
1135 #endif // WTF_ListHashSet_h 1144 #endif // WTF_ListHashSet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/LinkedHashSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698