[llvm-commits] [llvm] r65326 - in /llvm/trunk/include/llvm/ADT: ImmutableMap.h ImmutableSet.h
Ted Kremenek
kremenek at apple.com
Mon Feb 23 09:27:18 PST 2009
Author: kremenek
Date: Mon Feb 23 11:27:18 2009
New Revision: 65326
URL: http://llvm.org/viewvc/llvm-project?rev=65326&view=rev
Log:
Add ImmutableMap::getMaxElement(), a method that returns the <key,value> pair in a ImmutableMap that has the highest ranked key.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableMap.h
llvm/trunk/include/llvm/ADT/ImmutableSet.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=65326&r1=65325&r2=65326&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Mon Feb 23 11:27:18 2009
@@ -202,6 +202,13 @@
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.
Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=65326&r1=65325&r2=65326&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Mon Feb 23 11:27:18 2009
@@ -86,6 +86,15 @@
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.
More information about the llvm-commits
mailing list