From a76b1febd4fd258e8054395adedcbd477668d956 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 10 Feb 2007 06:34:58 +0000 Subject: [PATCH] Allow DenseMAp to take an explicit DenseMapKeyInfo git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34134 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 39 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index a156a8d3831..7e8b8c5e02f 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -40,12 +40,15 @@ struct DenseMapKeyInfo { static bool isPod() { return true; } }; -template +template > class DenseMapIterator; -template +template > class DenseMapConstIterator; -template +template > class DenseMap { typedef std::pair BucketT; unsigned NumBuckets; @@ -68,21 +71,19 @@ public: delete[] (char*)Buckets; } - typedef DenseMapIterator iterator; - typedef DenseMapConstIterator const_iterator; + typedef DenseMapIterator iterator; + typedef DenseMapConstIterator const_iterator; inline iterator begin() { - return DenseMapIterator(Buckets, Buckets+NumBuckets); + return iterator(Buckets, Buckets+NumBuckets); } inline iterator end() { - return DenseMapIterator(Buckets+NumBuckets, - Buckets+NumBuckets); + return iterator(Buckets+NumBuckets, Buckets+NumBuckets); } inline const_iterator begin() const { - return DenseMapConstIterator(Buckets, Buckets+NumBuckets); + return const_iterator(Buckets, Buckets+NumBuckets); } inline const_iterator end() const { - return DenseMapConstIterator(Buckets+NumBuckets, - Buckets+NumBuckets); + return const_iterator(Buckets+NumBuckets, Buckets+NumBuckets); } bool empty() const { return NumEntries == 0; } @@ -181,13 +182,13 @@ private: } static unsigned getHashValue(const KeyT &Val) { - return DenseMapKeyInfo::getHashValue(Val); + return KeyInfoT::getHashValue(Val); } static const KeyT getEmptyKey() { - return DenseMapKeyInfo::getEmptyKey(); + return KeyInfoT::getEmptyKey(); } static const KeyT getTombstoneKey() { - return DenseMapKeyInfo::getTombstoneKey(); + return KeyInfoT::getTombstoneKey(); } /// LookupBucketFor - Lookup the appropriate bucket for Val, returning it in @@ -285,7 +286,7 @@ private: } }; -template +template class DenseMapIterator { typedef std::pair BucketT; protected: @@ -320,16 +321,16 @@ public: private: void AdvancePastEmptyBuckets() { - const KeyT Empty = DenseMapKeyInfo::getEmptyKey(); - const KeyT Tombstone = DenseMapKeyInfo::getTombstoneKey(); + const KeyT Empty = KeyInfoT::getEmptyKey(); + const KeyT Tombstone = KeyInfoT::getTombstoneKey(); while (Ptr != End && (Ptr->first == Empty || Ptr->first == Tombstone)) ++Ptr; } }; -template -class DenseMapConstIterator : public DenseMapIterator { +template +class DenseMapConstIterator : public DenseMapIterator { public: DenseMapConstIterator(const std::pair *Pos, const std::pair *E) -- 2.34.1