mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Add ImmutableMap::getMaxElement(), a method that returns the <key,value> pair in a ImmutableMap that has the highest ranked key.
llvm-svn: 65326
This commit is contained in:
parent
f7d0d6fe22
commit
d8c425b68d
@ -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…
Reference in New Issue
Block a user