aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ADT/ImmutableSet.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-12 05:17:02 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-12 05:17:02 +0000
commitda5eb715509685f4a5cfdf6cd781827e72199af6 (patch)
treed4ae0ec9d9b1336559d6294d1ee9a7df89458678 /include/llvm/ADT/ImmutableSet.h
parentb7c9eeeede975251fe40e7355d0ee2c64c6df864 (diff)
Add method 'isSingleton()' to ImmutableSet. This returns true if the set contains exactly one element.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/ImmutableSet.h')
-rw-r--r--include/llvm/ADT/ImmutableSet.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h
index 03360359ea..5d2969f45a 100644
--- a/include/llvm/ADT/ImmutableSet.h
+++ b/include/llvm/ADT/ImmutableSet.h
@@ -61,7 +61,6 @@ public:
/// NULL if there is no right subtree.
ImutAVLTree* getRight() const { return Right; }
-
/// getHeight - Returns the height of the tree. A tree with no subtrees
/// has a height of 1.
unsigned getHeight() const { return Height; }
@@ -1001,6 +1000,10 @@ public:
/// isEmpty - Return true if the set contains no elements.
bool isEmpty() const { return !Root; }
+
+ /// isSingleton - Return true if the set contains exactly one element.
+ /// This method runs in constant time.
+ bool isSingleton() const { return getHeight() == 1; }
template <typename Callback>
void foreach(Callback& C) { if (Root) Root->foreach(C); }