Changeset 12328 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 23, 2006, 10:24:11 PM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r12321 r12328 1 2006-01-23 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Tim Omernick. 4 5 - use classes instead of free functions for extractors, this better matches how other 6 things work and should avoid the need for hacky workarounds on other compilers 7 http://bugzilla.opendarwin.org/show_bug.cgi?id=6748 8 9 * kjs/array_object.cpp: 10 * kjs/identifier.cpp: 11 * kjs/internal.cpp: 12 * kxmlcore/HashMap.h: 13 (KXMLCore::PairFirstExtractor::extract): 14 * kxmlcore/HashMapPtrSpec.h: 15 (KXMLCore::): 16 * kxmlcore/HashSet.h: 17 (KXMLCore::IdentityExtractor::extract): 18 * kxmlcore/HashTable.h: 19 (KXMLCore::addIterator): 20 (KXMLCore::removeIterator): 21 (KXMLCore::HashTable::add): 22 (KXMLCore::HashTable::isEmptyBucket): 23 (KXMLCore::HashTable::isDeletedBucket): 24 (KXMLCore::HashTable::HashTable): 25 (KXMLCore::HashTable::lookup): 26 (KXMLCore::HashTable::add): 27 (KXMLCore::HashTable::reinsert): 28 (KXMLCore::HashTable::find): 29 (KXMLCore::HashTable::contains): 30 (KXMLCore::HashTable::remove): 31 (KXMLCore::HashTable::allocateTable): 32 (KXMLCore::HashTable::deallocateTable): 33 (KXMLCore::HashTable::expand): 34 (KXMLCore::HashTable::rehash): 35 (KXMLCore::HashTable::clear): 36 (KXMLCore::HashTable::swap): 37 (KXMLCore::HashTable::operator): 38 (KXMLCore::HashTable::checkTableConsistency): 39 (KXMLCore::HashTable::checkTableConsistencyExceptSize): 40 (KXMLCore::HashTable::invalidateIterators): 41 1 42 2006-01-23 Maciej Stachowiak <[email protected]> 2 43 -
trunk/JavaScriptCore/kjs/array_object.cpp
r12321 r12328 39 39 #include <stdio.h> 40 40 #include <assert.h> 41 42 #ifdef WIN3243 template class KJS::JSObject * const & KXMLCore::identityExtract<class KJS::JSObject *>(class KJS::JSObject * const &);44 #endif45 41 46 42 using namespace KJS; -
trunk/JavaScriptCore/kjs/identifier.cpp
r12321 r12328 41 41 #include <string.h> // for strlen 42 42 #include <new> // for placement new 43 44 #ifdef WIN3245 template struct KJS::UString::Rep * const & KXMLCore::identityExtract<struct KJS::UString::Rep *>(struct KJS::UString::Rep * const &);46 #endif47 43 48 44 namespace KXMLCore { -
trunk/JavaScriptCore/kjs/internal.cpp
r12317 r12328 46 46 #include <math.h> 47 47 #include <stdio.h> 48 49 #if WIN3250 #include <float.h>51 #define copysign(a, b) _copysign(a, b)52 template void * const & KXMLCore::extractFirst<struct std::pair<void *,void *> >(struct std::pair<void *, void *> const &);53 #endif54 48 55 49 extern int kjsyyparse(); -
trunk/JavaScriptCore/kxmlcore/HashMap.h
r12321 r12328 30 30 namespace KXMLCore { 31 31 32 template<typename PairType> 33 inline typename PairType::first_type const& extractFirst(const PairType& value) 34 { 35 return value.first; 36 } 32 template<typename Key, typename Mapped> 33 class PairFirstExtractor 34 { 35 typedef pair<Key, Mapped> ValueType; 36 37 public: 38 static const Key& extract(const ValueType& value) 39 { 40 return value.first; 41 } 42 }; 37 43 38 44 template<typename Key, typename Mapped, typename HashFunctions> … … 68 74 typedef PairHashTraits<KeyTraits, MappedTraits> ValueTraits; 69 75 private: 70 typedef HashTable<KeyType, ValueType, extractFirst<ValueType>, HashFunctions, ValueTraits, KeyTraits> ImplType;76 typedef HashTable<KeyType, ValueType, PairFirstExtractor<KeyType, MappedType>, HashFunctions, ValueTraits, KeyTraits> ImplType; 71 77 typedef HashMapTranslator<Key, Mapped, HashFunctions> TranslatorType; 72 78 public: -
trunk/JavaScriptCore/kxmlcore/HashMapPtrSpec.h
r12301 r12328 181 181 typedef std::pair<KeyType, MappedType> ValueType; 182 182 typedef typename std::pair<void *, void *> ImplValueType; 183 typedef HashTableIterator<void *, ImplValueType, extractFirst<ImplValueType>, DefaultHash<void *>, PairHashTraits<HashTraits<void *>, HashTraits<void *> >, HashTraits<void *> > ImplIterator;184 typedef HashTableConstIterator<void *, ImplValueType, extractFirst<ImplValueType>, DefaultHash<void *>, PairHashTraits<HashTraits<void *>, HashTraits<void *> >, HashTraits<void *> > ImplConstIterator;183 typedef HashTableIterator<void *, ImplValueType, PairFirstExtractor<void *, void*>, DefaultHash<void *>, PairHashTraits<HashTraits<void *>, HashTraits<void *> >, HashTraits<void *> > ImplIterator; 184 typedef HashTableConstIterator<void *, ImplValueType, PairFirstExtractor<void *, void*>, DefaultHash<void *>, PairHashTraits<HashTraits<void *>, HashTraits<void *> >, HashTraits<void *> > ImplConstIterator; 185 185 186 186 typedef PointerHashIteratorAdapter<P, Q *> iterator; -
trunk/JavaScriptCore/kxmlcore/HashSet.h
r12321 r12328 31 31 32 32 template <typename T> 33 inline const T& identityExtract(const T& t) 34 { 35 return t; 36 } 37 33 struct IdentityExtractor 34 { 35 static const T& extract(const T& t) 36 { 37 return t; 38 } 39 }; 38 40 39 41 template<typename Value, typename T, typename HashSetTranslator> … … 59 61 class HashSet { 60 62 private: 61 typedef HashTable<Value, Value, identityExtract<Value>, HashFunctions, Traits, Traits> ImplType;63 typedef HashTable<Value, Value, IdentityExtractor<Value>, HashFunctions, Traits, Traits> ImplType; 62 64 public: 63 65 typedef Value ValueType; -
trunk/JavaScriptCore/kxmlcore/HashTable.h
r12321 r12328 56 56 #endif 57 57 58 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>58 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 59 59 class HashTable; 60 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>60 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 61 61 class HashTableIterator; 62 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>62 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 63 63 class HashTableConstIterator; 64 64 65 65 #if CHECK_HASHTABLE_ITERATORS 66 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>67 void addIterator(const HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*,68 HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*);69 70 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>71 void removeIterator(HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*);66 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 67 void addIterator(const HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*, 68 HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*); 69 70 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 71 void removeIterator(HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*); 72 72 #else 73 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>74 inline void addIterator(const HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*,75 HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*) { }76 77 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>78 inline void removeIterator(HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>*) { }79 #endif 80 81 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>73 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 74 inline void addIterator(const HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*, 75 HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*) { } 76 77 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 78 inline void removeIterator(HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>*) { } 79 #endif 80 81 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 82 82 class HashTableConstIterator { 83 83 private: 84 typedef HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> HashTableType;85 typedef HashTableIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> iterator;86 typedef HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> const_iterator;84 typedef HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> HashTableType; 85 typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> iterator; 86 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> const_iterator; 87 87 typedef Value ValueType; 88 88 typedef const ValueType& ReferenceType; 89 89 typedef const ValueType* PointerType; 90 90 91 friend class HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>;92 friend class HashTableIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>;91 friend class HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>; 92 friend class HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>; 93 93 94 94 void skipEmptyBuckets() … … 203 203 }; 204 204 205 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>205 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 206 206 class HashTableIterator { 207 207 private: 208 typedef HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> HashTableType;209 typedef HashTableIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> iterator;210 typedef HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> const_iterator;208 typedef HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> HashTableType; 209 typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> iterator; 210 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> const_iterator; 211 211 typedef Value ValueType; 212 212 typedef ValueType& ReferenceType; 213 213 typedef ValueType* PointerType; 214 214 215 friend class HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>;215 friend class HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>; 216 216 217 217 HashTableIterator(HashTableType* table, PointerType pos, PointerType end) : m_iterator(table, pos, end) { } … … 261 261 }; 262 262 263 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>263 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 264 264 class HashTable { 265 265 public: 266 typedef HashTableIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> iterator;267 typedef HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> const_iterator;266 typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> iterator; 267 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> const_iterator; 268 268 typedef Key KeyType; 269 269 typedef Value ValueType; … … 285 285 int capacity() const { return m_tableSize; } 286 286 287 pair<iterator, bool> add(const ValueType& value) { return add<KeyType, ValueType, IdentityTranslatorType>(Extract Key(value), value); }287 pair<iterator, bool> add(const ValueType& value) { return add<KeyType, ValueType, IdentityTranslatorType>(Extractor::extract(value), value); } 288 288 289 289 // A special version of add() that finds the object by hashing and comparing … … 300 300 void clear(); 301 301 302 static bool isEmptyBucket(const ValueType& value) { return Extract Key(value) == KeyTraits::emptyValue(); }303 static bool isDeletedBucket(const ValueType& value) { return Extract Key(value) == KeyTraits::deletedValue(); }302 static bool isEmptyBucket(const ValueType& value) { return Extractor::extract(value) == KeyTraits::emptyValue(); } 303 static bool isDeletedBucket(const ValueType& value) { return Extractor::extract(value) == KeyTraits::deletedValue(); } 304 304 static bool isEmptyOrDeletedBucket(const ValueType& value) { return isEmptyBucket(value) || isDeletedBucket(value); } 305 305 … … 364 364 }; 365 365 366 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>367 inline HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::HashTable()366 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 367 inline HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::HashTable() 368 368 : m_table(0) 369 369 , m_tableSize(0) … … 377 377 } 378 378 379 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>379 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 380 380 template<typename T, typename HashTranslator> 381 inline typename HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::FullLookupType HashTable<Key, Value, ExtractKey, HashFunctions, Traits, KeyTraits>::lookup(const T& key)381 inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::FullLookupType HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::lookup(const T& key) 382 382 { 383 383 assert(m_table); … … 399 399 if (isDeletedBucket(*entry)) 400 400 deletedEntry = entry; 401 else if (HashTranslator::equal(Extract Key(*entry), key))401 else if (HashTranslator::equal(Extractor::extract(*entry), key)) 402 402 return makeLookupResult(entry, true, h); 403 403 #if DUMP_HASHTABLE_STATS … … 414 414 415 415 416 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>416 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 417 417 template<typename T, typename Extra, typename HashTranslator> 418 inline pair<typename HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, ExtractKey, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra &extra)418 inline pair<typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra &extra) 419 419 { 420 420 invalidateIterators(); … … 444 444 // expand is rare, but would be better to have a version of expand that can 445 445 // follow a pivot entry and return the new position 446 KeyType enteredKey = Extract Key(*entry);446 KeyType enteredKey = Extractor::extract(*entry); 447 447 expand(); 448 448 return std::make_pair(find(enteredKey), true); … … 454 454 } 455 455 456 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>457 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::reinsert(ValueType& entry)456 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 457 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::reinsert(ValueType& entry) 458 458 { 459 459 assert(m_table); 460 assert(!lookup(Extract Key(entry)).second);461 assert(!isDeletedBucket(*(lookup(Extract Key(entry)).first)));460 assert(!lookup(Extractor::extract(entry)).second); 461 assert(!isDeletedBucket(*(lookup(Extractor::extract(entry)).first))); 462 462 #if DUMP_HASHTABLE_STATS 463 463 ++HashTableStats::numReinserts; 464 464 #endif 465 465 466 Mover<ValueType, Traits::needsDestruction>::move(entry, *(lookup(Extract Key(entry)).first));467 } 468 469 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>470 inline typename HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::iterator HashTable<Key, Value, ExtractKey, HashFunctions, Traits, KeyTraits>::find(const Key& key)466 Mover<ValueType, Traits::needsDestruction>::move(entry, *(lookup(Extractor::extract(entry)).first)); 467 } 468 469 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 470 inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const Key& key) 471 471 { 472 472 if (!m_table) … … 479 479 } 480 480 481 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>482 inline typename HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::const_iterator HashTable<Key, Value, ExtractKey, HashFunctions, Traits, KeyTraits>::find(const Key& key) const481 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 482 inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::const_iterator HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::find(const Key& key) const 483 483 { 484 484 if (!m_table) … … 491 491 } 492 492 493 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>494 inline bool HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::contains(const KeyType& key) const493 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 494 inline bool HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::contains(const KeyType& key) const 495 495 { 496 496 if (!m_table) … … 500 500 } 501 501 502 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>503 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::remove(ValueType* pos)502 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 503 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::remove(ValueType* pos) 504 504 { 505 505 invalidateIterators(); … … 520 520 } 521 521 522 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>523 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::remove(const KeyType& key)522 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 523 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::remove(const KeyType& key) 524 524 { 525 525 if (!m_table) … … 529 529 } 530 530 531 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>532 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::remove(iterator it)531 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 532 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::remove(iterator it) 533 533 { 534 534 if (it == end()) … … 539 539 540 540 541 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>542 inline Value *HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::allocateTable(int size)541 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 542 inline Value *HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::allocateTable(int size) 543 543 { 544 544 // would use a template member function with explicit specializations here, but … … 555 555 } 556 556 557 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>558 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::deallocateTable(ValueType *table, int size)557 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 558 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::deallocateTable(ValueType *table, int size) 559 559 { 560 560 if (Traits::needsDestruction) { … … 567 567 } 568 568 569 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>570 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::expand()569 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 570 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::expand() 571 571 { 572 572 int newSize; … … 581 581 } 582 582 583 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>584 void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::rehash(int newTableSize)583 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 584 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::rehash(int newTableSize) 585 585 { 586 586 checkTableConsistencyExceptSize(); … … 610 610 } 611 611 612 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>613 inline void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::clear()612 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 613 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::clear() 614 614 { 615 615 invalidateIterators(); … … 621 621 } 622 622 623 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>624 HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::HashTable(const HashTable& other)623 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 624 HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::HashTable(const HashTable& other) 625 625 : m_table(0) 626 626 , m_tableSize(0) … … 639 639 } 640 640 641 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>642 void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::swap(HashTable& other)641 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 642 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::swap(HashTable& other) 643 643 { 644 644 invalidateIterators(); … … 666 666 } 667 667 668 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>669 HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>& HashTable<Key, Value, ExtractKey, HashFunctions, Traits, KeyTraits>::operator=(const HashTable& other)668 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 669 HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>& HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::operator=(const HashTable& other) 670 670 { 671 671 HashTable tmp(other); … … 676 676 #if CHECK_HASHTABLE_CONSISTENCY 677 677 678 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>679 void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::checkTableConsistency() const678 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 679 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::checkTableConsistency() const 680 680 { 681 681 checkTableConsistencyExceptSize(); … … 684 684 } 685 685 686 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>687 void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::checkTableConsistencyExceptSize() const686 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 687 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::checkTableConsistencyExceptSize() const 688 688 { 689 689 if (!m_table) … … 702 702 } 703 703 704 const_iterator it = find(Extract Key(*entry));704 const_iterator it = find(Extractor::extract(*entry)); 705 705 assert(entry == it.m_position); 706 706 ++count; … … 718 718 #if CHECK_HASHTABLE_ITERATORS 719 719 720 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>721 void HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>::invalidateIterators()720 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 721 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::invalidateIterators() 722 722 { 723 723 const_iterator* next; … … 731 731 } 732 732 733 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>734 void addIterator(const HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>* table,735 HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>* it)733 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 734 void addIterator(const HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>* table, 735 HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>* it) 736 736 { 737 737 it->m_table = table; … … 752 752 } 753 753 754 template<typename Key, typename Value, const Key& ExtractKey(const Value&), typename HashFunctions, typename Traits, typename KeyTraits>755 void removeIterator(HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits>* it)756 { 757 typedef HashTable<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> HashTableType;758 typedef HashTableConstIterator<Key, Value, Extract Key, HashFunctions, Traits, KeyTraits> const_iterator;754 template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits> 755 void removeIterator(HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>* it) 756 { 757 typedef HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> HashTableType; 758 typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> const_iterator; 759 759 760 760 // Delete iterator from doubly-linked list of iterators.
Note:
See TracChangeset
for help on using the changeset viewer.