mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-17 21:32:04 +00:00
Add ImmutableMap::getMaxElement(), a method that returns the <key,value> pair in a ImmutableMap that has the highest ranked key.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65326 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e2abdd3ff0
commit
1c7a666fce
@ -202,6 +202,13 @@ public:
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
|
||||
/// which key is the highest in the ordering of keys in the map. This
|
||||
/// method returns NULL if the map is empty.
|
||||
value_type* getMaxElement() const {
|
||||
return Root ? &(Root->getMaxElement()) : 0;
|
||||
}
|
||||
|
||||
//===--------------------------------------------------===//
|
||||
// Utility methods.
|
||||
|
@ -86,6 +86,15 @@ public:
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// getMaxElement - Find the subtree associated with the highest ranged
|
||||
/// key value.
|
||||
ImutAVLTree* getMaxElement() {
|
||||
ImutAVLTree *T = this;
|
||||
ImutAVLTree *Right = T->getRight();
|
||||
while (Right) { T = Right; Right = T->getRight(); }
|
||||
return T;
|
||||
}
|
||||
|
||||
/// size - Returns the number of nodes in the tree, which includes
|
||||
/// both leaves and non-leaf nodes.
|
||||
|
Loading…
x
Reference in New Issue
Block a user