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

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

Issue 2759703002: Migrate WTF::HashMap::remove() to ::erase() (Closed)
Patch Set: rebase, fix one platform-specific reference 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
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.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 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // new value was actually added 143 // new value was actually added
144 template <typename IncomingKeyType, typename IncomingMappedType> 144 template <typename IncomingKeyType, typename IncomingMappedType>
145 AddResult set(IncomingKeyType&&, IncomingMappedType&&); 145 AddResult set(IncomingKeyType&&, IncomingMappedType&&);
146 146
147 // does nothing if key is already present return value is a pair of the 147 // does nothing if key is already present return value is a pair of the
148 // iterator to the key location, and a boolean that's true if a new value 148 // iterator to the key location, and a boolean that's true if a new value
149 // was actually added 149 // was actually added
150 template <typename IncomingKeyType, typename IncomingMappedType> 150 template <typename IncomingKeyType, typename IncomingMappedType>
151 AddResult insert(IncomingKeyType&&, IncomingMappedType&&); 151 AddResult insert(IncomingKeyType&&, IncomingMappedType&&);
152 152
153 // TODO(pilgrim) remove remove() method once all references migrated to
154 // erase()
155 // https://crbug.com/662431
156 void remove(KeyPeekInType);
157 void erase(KeyPeekInType); 153 void erase(KeyPeekInType);
158 void remove(iterator); 154 void erase(iterator);
159 void clear(); 155 void clear();
160 template <typename Collection> 156 template <typename Collection>
161 void removeAll(const Collection& toBeRemoved) { 157 void removeAll(const Collection& toBeRemoved) {
162 WTF::removeAll(*this, toBeRemoved); 158 WTF::removeAll(*this, toBeRemoved);
163 } 159 }
164 160
165 MappedType take(KeyPeekInType); // efficient combination of get with remove 161 MappedType take(KeyPeekInType); // efficient combination of get with remove
166 162
167 // An alternate version of find() that finds the object by hashing and 163 // An alternate version of find() that finds the object by hashing and
168 // comparing with some other type, to avoid the cost of type 164 // comparing with some other type, to avoid the cost of type
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 return MappedTraits::peek(MappedTraits::emptyValue()); 597 return MappedTraits::peek(MappedTraits::emptyValue());
602 return MappedTraits::peek(entry->value); 598 return MappedTraits::peek(entry->value);
603 } 599 }
604 600
605 template <typename T, 601 template <typename T,
606 typename U, 602 typename U,
607 typename V, 603 typename V,
608 typename W, 604 typename W,
609 typename X, 605 typename X,
610 typename Y> 606 typename Y>
611 inline void HashMap<T, U, V, W, X, Y>::remove(iterator it) { 607 inline void HashMap<T, U, V, W, X, Y>::erase(iterator it) {
612 m_impl.remove(it.m_impl); 608 m_impl.remove(it.m_impl);
613 } 609 }
614 610
615 template <typename T, 611 template <typename T,
616 typename U, 612 typename U,
617 typename V, 613 typename V,
618 typename W, 614 typename W,
619 typename X, 615 typename X,
620 typename Y> 616 typename Y>
621 inline void HashMap<T, U, V, W, X, Y>::remove(KeyPeekInType key) {
622 remove(find(key));
623 }
624
625 template <typename T,
626 typename U,
627 typename V,
628 typename W,
629 typename X,
630 typename Y>
631 inline void HashMap<T, U, V, W, X, Y>::erase(KeyPeekInType key) { 617 inline void HashMap<T, U, V, W, X, Y>::erase(KeyPeekInType key) {
632 remove(find(key)); 618 erase(find(key));
633 } 619 }
634 620
635 template <typename T, 621 template <typename T,
636 typename U, 622 typename U,
637 typename V, 623 typename V,
638 typename W, 624 typename W,
639 typename X, 625 typename X,
640 typename Y> 626 typename Y>
641 inline void HashMap<T, U, V, W, X, Y>::clear() { 627 inline void HashMap<T, U, V, W, X, Y>::clear() {
642 m_impl.clear(); 628 m_impl.clear();
643 } 629 }
644 630
645 template <typename T, 631 template <typename T,
646 typename U, 632 typename U,
647 typename V, 633 typename V,
648 typename W, 634 typename W,
649 typename X, 635 typename X,
650 typename Y> 636 typename Y>
651 auto HashMap<T, U, V, W, X, Y>::take(KeyPeekInType key) -> MappedType { 637 auto HashMap<T, U, V, W, X, Y>::take(KeyPeekInType key) -> MappedType {
652 iterator it = find(key); 638 iterator it = find(key);
653 if (it == end()) 639 if (it == end())
654 return MappedTraits::emptyValue(); 640 return MappedTraits::emptyValue();
655 MappedType result = std::move(it->value); 641 MappedType result = std::move(it->value);
656 remove(it); 642 erase(it);
657 return result; 643 return result;
658 } 644 }
659 645
660 template <typename T, 646 template <typename T,
661 typename U, 647 typename U,
662 typename V, 648 typename V,
663 typename W, 649 typename W,
664 typename X, 650 typename X,
665 typename Y> 651 typename Y>
666 inline bool HashMap<T, U, V, W, X, Y>::isValidKey(KeyPeekInType key) { 652 inline bool HashMap<T, U, V, W, X, Y>::isValidKey(KeyPeekInType key) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 iterator end = collection.end().values(); 737 iterator end = collection.end().values();
752 for (unsigned i = 0; it != end; ++it, ++i) 738 for (unsigned i = 0; it != end; ++it, ++i)
753 vector[i] = *it; 739 vector[i] = *it;
754 } 740 }
755 741
756 } // namespace WTF 742 } // namespace WTF
757 743
758 using WTF::HashMap; 744 using WTF::HashMap;
759 745
760 #endif // WTF_HashMap_h 746 #endif // WTF_HashMap_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698