Changeset 102084 in webkit
- Timestamp:
- Dec 5, 2011, 6:17:22 PM (15 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
wtf/HashMap.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r102082 r102084 1 2011-12-05 Anders Carlsson <andersca@apple.com> 2 3 Add HashMap::keys() and HashMap::values() for easy iteration of hash map keys and values in C++11. 4 5 Reviewed by Darin Adler. 6 7 * wtf/HashMap.h: 8 1 9 2011-12-05 Michael Saboff <msaboff@apple.com> 2 10 -
trunk/Source/JavaScriptCore/wtf/HashMap.h
r101942 r102084 61 61 HashFunctions, ValueTraits, KeyTraits> HashTableType; 62 62 63 class HashMapKeysProxy; 64 class HashMapValuesProxy; 65 63 66 public: 64 67 typedef HashTableIteratorAdapter<HashTableType, ValueType> iterator; 65 68 typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator; 66 69 70 public: 67 71 void swap(HashMap&); 68 72 … … 76 80 const_iterator begin() const; 77 81 const_iterator end() const; 82 83 HashMapKeysProxy& keys() { return static_cast<HashMapKeysProxy&>(*this); } 84 const HashMapKeysProxy& keys() const { return static_cast<const HashMapKeysProxy&>(*this); } 85 86 HashMapValuesProxy& values() { return static_cast<HashMapValuesProxy&>(*this); } 87 const HashMapValuesProxy& values() const { return static_cast<const HashMapValuesProxy&>(*this); } 78 88 79 89 iterator find(const KeyType&); … … 119 129 private: 120 130 pair<iterator, bool> inlineAdd(const KeyType&, MappedPassInReferenceType); 131 132 class HashMapKeysProxy : private HashMap { 133 public: 134 typedef typename HashMap::iterator::Keys iterator; 135 typedef typename HashMap::const_iterator::Keys const_iterator; 136 137 iterator begin() 138 { 139 return HashMap::begin().keys(); 140 } 141 142 iterator end() 143 { 144 return HashMap::end().keys(); 145 } 146 147 const_iterator begin() const 148 { 149 return HashMap::begin().keys(); 150 } 151 152 const_iterator end() const 153 { 154 return HashMap::end().keys(); 155 } 156 157 private: 158 friend class HashMap; 159 160 // These are intentionally not implemented. 161 HashMapKeysProxy(); 162 HashMapKeysProxy(const HashMapKeysProxy&); 163 HashMapKeysProxy& operator=(const HashMapKeysProxy&); 164 ~HashMapKeysProxy(); 165 }; 166 167 class HashMapValuesProxy : private HashMap { 168 public: 169 typedef typename HashMap::iterator::Values iterator; 170 typedef typename HashMap::const_iterator::Values const_iterator; 171 172 iterator begin() 173 { 174 return HashMap::begin().values(); 175 } 176 177 iterator end() 178 { 179 return HashMap::end().values(); 180 } 181 182 const_iterator begin() const 183 { 184 return HashMap::begin().values(); 185 } 186 187 const_iterator end() const 188 { 189 return HashMap::end().values(); 190 } 191 192 private: 193 friend class HashMap; 194 195 // These are intentionally not implemented. 196 HashMapValuesProxy(); 197 HashMapValuesProxy(const HashMapValuesProxy&); 198 HashMapValuesProxy& operator=(const HashMapValuesProxy&); 199 ~HashMapValuesProxy(); 200 }; 121 201 122 202 HashTableType m_impl;
Note:
See TracChangeset
for help on using the changeset viewer.