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

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

Issue 2724363002: Migrate WTF::LinkedHashSet/ListHashSet::add() to ::insert() (Closed)
Patch Set: Created 3 years, 9 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
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // An alternate version of find() that finds the object by hashing and 250 // An alternate version of find() that finds the object by hashing and
251 // comparing with some other type, to avoid the cost of type conversion. 251 // comparing with some other type, to avoid the cost of type conversion.
252 // The HashTranslator interface is defined in HashSet. 252 // The HashTranslator interface is defined in HashSet.
253 template <typename HashTranslator, typename T> 253 template <typename HashTranslator, typename T>
254 iterator find(const T&); 254 iterator find(const T&);
255 template <typename HashTranslator, typename T> 255 template <typename HashTranslator, typename T>
256 const_iterator find(const T&) const; 256 const_iterator find(const T&) const;
257 template <typename HashTranslator, typename T> 257 template <typename HashTranslator, typename T>
258 bool contains(const T&) const; 258 bool contains(const T&) const;
259 259
260 // The return value of add is a pair of a pointer to the stored value, 260 // The return value of insert is a pair of a pointer to the stored value,
261 // and a bool that is true if an new entry was added. 261 // and a bool that is true if an new entry was added.
262 template <typename IncomingValueType> 262 template <typename IncomingValueType>
263 AddResult add(IncomingValueType&&);
264 template <typename IncomingValueType>
265 AddResult insert(IncomingValueType&&); 263 AddResult insert(IncomingValueType&&);
266 264
267 // Same as add() except that the return value is an 265 // Same as insert() except that the return value is an
268 // iterator. Useful in cases where it's needed to have the 266 // iterator. Useful in cases where it's needed to have the
269 // same return value as find() and where it's not possible to 267 // same return value as find() and where it's not possible to
270 // use a pointer to the storedValue. 268 // use a pointer to the storedValue.
271 template <typename IncomingValueType> 269 template <typename IncomingValueType>
272 iterator addReturnIterator(IncomingValueType&&); 270 iterator addReturnIterator(IncomingValueType&&);
273 271
274 // Add the value to the end of the collection. If the value was already in 272 // Add the value to the end of the collection. If the value was already in
275 // the list, it is moved to the end. 273 // the list, it is moved to the end.
276 template <typename IncomingValueType> 274 template <typename IncomingValueType>
277 AddResult appendOrMoveToLast(IncomingValueType&&); 275 AddResult appendOrMoveToLast(IncomingValueType&&);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 !IsPointerToGarbageCollectedType<T>::value, 656 !IsPointerToGarbageCollectedType<T>::value,
659 "Cannot put raw pointers to garbage-collected classes into " 657 "Cannot put raw pointers to garbage-collected classes into "
660 "an off-heap LinkedHashSet. Use HeapLinkedHashSet<Member<T>> instead."); 658 "an off-heap LinkedHashSet. Use HeapLinkedHashSet<Member<T>> instead.");
661 } 659 }
662 660
663 template <typename T, typename U, typename V, typename W> 661 template <typename T, typename U, typename V, typename W>
664 inline LinkedHashSet<T, U, V, W>::LinkedHashSet(const LinkedHashSet& other) 662 inline LinkedHashSet<T, U, V, W>::LinkedHashSet(const LinkedHashSet& other)
665 : m_anchor() { 663 : m_anchor() {
666 const_iterator end = other.end(); 664 const_iterator end = other.end();
667 for (const_iterator it = other.begin(); it != end; ++it) 665 for (const_iterator it = other.begin(); it != end; ++it)
668 add(*it); 666 insert(*it);
669 } 667 }
670 668
671 template <typename T, typename U, typename V, typename W> 669 template <typename T, typename U, typename V, typename W>
672 inline LinkedHashSet<T, U, V, W>::LinkedHashSet(LinkedHashSet&& other) 670 inline LinkedHashSet<T, U, V, W>::LinkedHashSet(LinkedHashSet&& other)
673 : m_anchor() { 671 : m_anchor() {
674 swap(other); 672 swap(other);
675 } 673 }
676 674
677 template <typename T, typename U, typename V, typename W> 675 template <typename T, typename U, typename V, typename W>
678 inline LinkedHashSet<T, U, V, W>& LinkedHashSet<T, U, V, W>::operator=( 676 inline LinkedHashSet<T, U, V, W>& LinkedHashSet<T, U, V, W>::operator=(
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 inline bool LinkedHashSet<T, U, V, W>::contains(ValuePeekInType value) const { 805 inline bool LinkedHashSet<T, U, V, W>::contains(ValuePeekInType value) const {
808 return m_impl.template contains<NodeHashFunctions>(value); 806 return m_impl.template contains<NodeHashFunctions>(value);
809 } 807 }
810 808
811 template <typename Value, 809 template <typename Value,
812 typename HashFunctions, 810 typename HashFunctions,
813 typename Traits, 811 typename Traits,
814 typename Allocator> 812 typename Allocator>
815 template <typename IncomingValueType> 813 template <typename IncomingValueType>
816 typename LinkedHashSet<Value, HashFunctions, Traits, Allocator>::AddResult 814 typename LinkedHashSet<Value, HashFunctions, Traits, Allocator>::AddResult
817 LinkedHashSet<Value, HashFunctions, Traits, Allocator>::add( 815 LinkedHashSet<Value, HashFunctions, Traits, Allocator>::insert(
818 IncomingValueType&& value) { 816 IncomingValueType&& value) {
819 return m_impl.template add<NodeHashFunctions>( 817 return m_impl.template add<NodeHashFunctions>(
820 std::forward<IncomingValueType>(value), &m_anchor); 818 std::forward<IncomingValueType>(value), &m_anchor);
821 } 819 }
822 820
823 template <typename Value,
824 typename HashFunctions,
825 typename Traits,
826 typename Allocator>
827 template <typename IncomingValueType>
828 typename LinkedHashSet<Value, HashFunctions, Traits, Allocator>::AddResult
829 LinkedHashSet<Value, HashFunctions, Traits, Allocator>::insert(
830 IncomingValueType&& value) {
831 return add(value);
832 }
833
834 template <typename T, typename U, typename V, typename W> 821 template <typename T, typename U, typename V, typename W>
835 template <typename IncomingValueType> 822 template <typename IncomingValueType>
836 typename LinkedHashSet<T, U, V, W>::iterator 823 typename LinkedHashSet<T, U, V, W>::iterator
837 LinkedHashSet<T, U, V, W>::addReturnIterator(IncomingValueType&& value) { 824 LinkedHashSet<T, U, V, W>::addReturnIterator(IncomingValueType&& value) {
838 typename ImplType::AddResult result = m_impl.template add<NodeHashFunctions>( 825 typename ImplType::AddResult result = m_impl.template add<NodeHashFunctions>(
839 std::forward<IncomingValueType>(value), &m_anchor); 826 std::forward<IncomingValueType>(value), &m_anchor);
840 return makeIterator(result.storedValue); 827 return makeIterator(result.storedValue);
841 } 828 }
842 829
843 template <typename T, typename U, typename V, typename W> 830 template <typename T, typename U, typename V, typename W>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 swap(static_cast<Base&>(a), static_cast<Base&>(b)); 929 swap(static_cast<Base&>(a), static_cast<Base&>(b));
943 swap(a.m_value, b.m_value); 930 swap(a.m_value, b.m_value);
944 Allocator::leaveGCForbiddenScope(); 931 Allocator::leaveGCForbiddenScope();
945 } 932 }
946 933
947 } // namespace WTF 934 } // namespace WTF
948 935
949 using WTF::LinkedHashSet; 936 using WTF::LinkedHashSet;
950 937
951 #endif /* WTF_LinkedHashSet_h */ 938 #endif /* WTF_LinkedHashSet_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp ('k') | third_party/WebKit/Source/wtf/ListHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698