[llvm-commits] [llvm] r64359 - /llvm/trunk/include/llvm/ADT/ImmutableSet.h
Ted Kremenek
kremenek at apple.com
Wed Feb 11 21:17:03 PST 2009
Author: kremenek
Date: Wed Feb 11 23:17:02 2009
New Revision: 64359
URL: http://llvm.org/viewvc/llvm-project?rev=64359&view=rev
Log:
Add method 'isSingleton()' to ImmutableSet. This returns true if the set contains exactly one element.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableSet.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=64359&r1=64358&r2=64359&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Wed Feb 11 23:17:02 2009
@@ -61,7 +61,6 @@
/// 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 @@
/// 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); }
More information about the llvm-commits
mailing list