mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
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
This commit is contained in:
@@ -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; }
|
||||
@@ -1002,6 +1001,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); }
|
||||
|
||||
|
Reference in New Issue
Block a user