1
0
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:
Ted Kremenek 2009-02-23 17:27:18 +00:00
parent f7d0d6fe22
commit d8c425b68d
2 changed files with 16 additions and 0 deletions

View File

@ -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.

View File

@ -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.