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

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

Issue 2709033003: Migrate WTF::HashMap::get() to ::at() (Closed)
Patch Set: rebase 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 HashMapValuesProxy& values() { 129 HashMapValuesProxy& values() {
130 return static_cast<HashMapValuesProxy&>(*this); 130 return static_cast<HashMapValuesProxy&>(*this);
131 } 131 }
132 const HashMapValuesProxy& values() const { 132 const HashMapValuesProxy& values() const {
133 return static_cast<const HashMapValuesProxy&>(*this); 133 return static_cast<const HashMapValuesProxy&>(*this);
134 } 134 }
135 135
136 iterator find(KeyPeekInType); 136 iterator find(KeyPeekInType);
137 const_iterator find(KeyPeekInType) const; 137 const_iterator find(KeyPeekInType) const;
138 bool contains(KeyPeekInType) const; 138 bool contains(KeyPeekInType) const;
139 MappedPeekType get(KeyPeekInType) const; 139 MappedPeekType at(KeyPeekInType) const;
140 140
141 // replaces value but not key if key is already present return value is a 141 // replaces value but not key if key is already present return value is a
142 // pair of the iterator to the key location, and a boolean that's true if a 142 // pair of the iterator to the key location, and a boolean that's true if a
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
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 std::forward<IncomingMappedType>(mapped)); 588 std::forward<IncomingMappedType>(mapped));
589 } 589 }
590 590
591 template <typename T, 591 template <typename T,
592 typename U, 592 typename U,
593 typename V, 593 typename V,
594 typename W, 594 typename W,
595 typename X, 595 typename X,
596 typename Y> 596 typename Y>
597 typename HashMap<T, U, V, W, X, Y>::MappedPeekType 597 typename HashMap<T, U, V, W, X, Y>::MappedPeekType
598 HashMap<T, U, V, W, X, Y>::get(KeyPeekInType key) const { 598 HashMap<T, U, V, W, X, Y>::at(KeyPeekInType key) const {
599 ValueType* entry = const_cast<HashTableType&>(m_impl).lookup(key); 599 ValueType* entry = const_cast<HashTableType&>(m_impl).lookup(key);
600 if (!entry) 600 if (!entry)
601 return MappedTraits::peek(MappedTraits::emptyValue()); 601 return MappedTraits::peek(MappedTraits::emptyValue());
602 return MappedTraits::peek(entry->value); 602 return MappedTraits::peek(entry->value);
603 } 603 }
604 604
605 template <typename T, 605 template <typename T,
606 typename U, 606 typename U,
607 typename V, 607 typename V,
608 typename W, 608 typename W,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 iterator end = collection.end().values(); 751 iterator end = collection.end().values();
752 for (unsigned i = 0; it != end; ++it, ++i) 752 for (unsigned i = 0; it != end; ++it, ++i)
753 vector[i] = *it; 753 vector[i] = *it;
754 } 754 }
755 755
756 } // namespace WTF 756 } // namespace WTF
757 757
758 using WTF::HashMap; 758 using WTF::HashMap;
759 759
760 #endif // WTF_HashMap_h 760 #endif // WTF_HashMap_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.h ('k') | third_party/WebKit/Source/wtf/HashMapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698