aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/SmallPtrSet.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-27 07:59:10 +0000
committerChris Lattner <sabre@nondot.org>2007-01-27 07:59:10 +0000
commit0b930852cf1a9899ae82dd6c31b43e754a77dcb0 (patch)
treee67e5cea4cc09e19fa639cc56c22cf24bada4be9 /include/llvm/ADT/SmallPtrSet.h
parentaf3056c97e56106af7c3b9a5c856d1dc1d21e358 (diff)
downloadexternal_llvm-0b930852cf1a9899ae82dd6c31b43e754a77dcb0.tar.gz
external_llvm-0b930852cf1a9899ae82dd6c31b43e754a77dcb0.tar.bz2
external_llvm-0b930852cf1a9899ae82dd6c31b43e754a77dcb0.zip
implement SmallPtrSet::erase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallPtrSet.h')
-rw-r--r--include/llvm/ADT/SmallPtrSet.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h
index d2a68ff90f..b9f7b1fc26 100644
--- a/include/llvm/ADT/SmallPtrSet.h
+++ b/include/llvm/ADT/SmallPtrSet.h
@@ -67,8 +67,6 @@ public:
delete[] CurArray;
}
- bool isSmall() const { return CurArray == &SmallArray[0]; }
-
static void *getTombstoneMarker() { return reinterpret_cast<void*>(-2); }
static void *getEmptyMarker() {
// Note that -1 is chosen to make clear() efficiently implementable with
@@ -86,6 +84,10 @@ public:
/// was already in the set.
bool insert(void *Ptr);
+ /// erase - If the set contains the specified pointer, remove it and return
+ /// true, otherwise return false.
+ bool erase(void *Ptr);
+
bool count(void *Ptr) const {
if (isSmall()) {
// Linear search for the item.
@@ -101,6 +103,8 @@ public:
}
private:
+ bool isSmall() const { return CurArray == &SmallArray[0]; }
+
unsigned Hash(void *Ptr) const {
return ((uintptr_t)Ptr >> 4) & (CurArraySize-1);
}
@@ -188,7 +192,10 @@ struct NextPowerOfTwo {
};
-/// SmallPtrSet - This class implements
+/// SmallPtrSet - This class implements a set which is optimizer for holding
+/// SmallSize or less elements. This internally rounds up SmallSize to the next
+/// power of two if it is not already a power of two. See the comments above
+/// SmallPtrSetImpl for details of the algorithm.
template<class PtrType, unsigned SmallSize>
class SmallPtrSet : public SmallPtrSetImpl {
// Make sure that SmallSize is a power of two, round up if not.