| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2008 David Levin <levin@chromium.org> | 3 * Copyright (C) 2008 David Levin <levin@chromium.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 public: | 292 public: |
| 293 typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits,
KeyTraits, Allocator> iterator; | 293 typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits,
KeyTraits, Allocator> iterator; |
| 294 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Tra
its, KeyTraits, Allocator> const_iterator; | 294 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Tra
its, KeyTraits, Allocator> const_iterator; |
| 295 typedef Traits ValueTraits; | 295 typedef Traits ValueTraits; |
| 296 typedef Key KeyType; | 296 typedef Key KeyType; |
| 297 typedef typename KeyTraits::PeekInType KeyPeekInType; | 297 typedef typename KeyTraits::PeekInType KeyPeekInType; |
| 298 typedef typename KeyTraits::PassInType KeyPassInType; | 298 typedef typename KeyTraits::PassInType KeyPassInType; |
| 299 typedef Value ValueType; | 299 typedef Value ValueType; |
| 300 typedef Extractor ExtractorType; | 300 typedef Extractor ExtractorType; |
| 301 typedef KeyTraits KeyTraitsType; | 301 typedef KeyTraits KeyTraitsType; |
| 302 typedef typename Traits::PeekInType ValuePeekInType; | 302 typedef typename Traits::PassInType ValuePassInType; |
| 303 typedef IdentityHashTranslator<HashFunctions> IdentityTranslatorType; | 303 typedef IdentityHashTranslator<HashFunctions> IdentityTranslatorType; |
| 304 typedef HashTableAddResult<HashTable, ValueType> AddResult; | 304 typedef HashTableAddResult<HashTable, ValueType> AddResult; |
| 305 | 305 |
| 306 #if DUMP_HASHTABLE_STATS_PER_TABLE | 306 #if DUMP_HASHTABLE_STATS_PER_TABLE |
| 307 struct Stats { | 307 struct Stats { |
| 308 Stats() | 308 Stats() |
| 309 : numAccesses(0) | 309 : numAccesses(0) |
| 310 , numRehashes(0) | 310 , numRehashes(0) |
| 311 , numRemoves(0) | 311 , numRemoves(0) |
| 312 , numReinserts(0) | 312 , numReinserts(0) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // buckets, and iterating an empty table is a common case that's worth o
ptimizing. | 367 // buckets, and iterating an empty table is a common case that's worth o
ptimizing. |
| 368 iterator begin() { return isEmpty() ? end() : makeIterator(m_table); } | 368 iterator begin() { return isEmpty() ? end() : makeIterator(m_table); } |
| 369 iterator end() { return makeKnownGoodIterator(m_table + m_tableSize); } | 369 iterator end() { return makeKnownGoodIterator(m_table + m_tableSize); } |
| 370 const_iterator begin() const { return isEmpty() ? end() : makeConstItera
tor(m_table); } | 370 const_iterator begin() const { return isEmpty() ? end() : makeConstItera
tor(m_table); } |
| 371 const_iterator end() const { return makeKnownGoodConstIterator(m_table +
m_tableSize); } | 371 const_iterator end() const { return makeKnownGoodConstIterator(m_table +
m_tableSize); } |
| 372 | 372 |
| 373 unsigned size() const { return m_keyCount; } | 373 unsigned size() const { return m_keyCount; } |
| 374 unsigned capacity() const { return m_tableSize; } | 374 unsigned capacity() const { return m_tableSize; } |
| 375 bool isEmpty() const { return !m_keyCount; } | 375 bool isEmpty() const { return !m_keyCount; } |
| 376 | 376 |
| 377 AddResult add(ValuePeekInType value) | 377 AddResult add(ValuePassInType value) |
| 378 { | 378 { |
| 379 return add<IdentityTranslatorType>(Extractor::extract(value), value)
; | 379 return add<IdentityTranslatorType>(Extractor::extract(value), value)
; |
| 380 } | 380 } |
| 381 | 381 |
| 382 // A special version of add() that finds the object by hashing and compa
ring | 382 // A special version of add() that finds the object by hashing and compa
ring |
| 383 // with some other type, to avoid the cost of type conversion if the obj
ect is already | 383 // with some other type, to avoid the cost of type conversion if the obj
ect is already |
| 384 // in the table. | 384 // in the table. |
| 385 template<typename HashTranslator, typename T, typename Extra> AddResult
add(const T& key, const Extra&); | 385 template<typename HashTranslator, typename T, typename Extra> AddResult
add(const T& key, const Extra&); |
| 386 template<typename HashTranslator, typename T, typename Extra> AddResult
addPassingHashCode(const T& key, const Extra&); | 386 template<typename HashTranslator, typename T, typename Extra> AddResult
addPassingHashCode(const T& key, const Extra&); |
| 387 | 387 |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 CollectionIterator end(toBeRemoved.end()); | 1286 CollectionIterator end(toBeRemoved.end()); |
| 1287 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1287 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
| 1288 collection.remove(*it); | 1288 collection.remove(*it); |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 } // namespace WTF | 1291 } // namespace WTF |
| 1292 | 1292 |
| 1293 #include "wtf/HashIterators.h" | 1293 #include "wtf/HashIterators.h" |
| 1294 | 1294 |
| 1295 #endif // WTF_HashTable_h | 1295 #endif // WTF_HashTable_h |
| OLD | NEW |