aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2001-05-07 15:45:24 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2001-05-07 15:45:24 +0000
commit5cdba4ff5fcb672b983d5dbffba74d89b899a2ab (patch)
treef4070967fe8b5e20c049120c92a27ab4519f2986 /libiberty
parentb73bff7e3f78151ef33441bd66e8ac3df12f0b80 (diff)
downloadgcc-5cdba4ff5fcb672b983d5dbffba74d89b899a2ab.tar.gz
gcc-5cdba4ff5fcb672b983d5dbffba74d89b899a2ab.tar.bz2
gcc-5cdba4ff5fcb672b983d5dbffba74d89b899a2ab.zip
splay-tree.h (splay_tree_max): New function.
* splay-tree.h (splay_tree_max): New function. (splay_tree_min): Likewise. From-SVN: r41895
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/splay-tree.c36
2 files changed, 40 insertions, 1 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 53e4290dd30..9f635430edc 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2001-05-07 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.h (splay_tree_max): New function.
+ (splay_tree_min): Likewise.
+
2001-04-15 Daniel Berlin <dan@cgsoftware.com>
* ternary.c: New file - Ternary search tree implementation.
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index 52b57c088a7..a7123952671 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -1,5 +1,5 @@
/* A splay-tree datatype.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GNU CC.
@@ -368,6 +368,40 @@ splay_tree_lookup (sp, key)
return 0;
}
+/* Return the node in SP with the greatest key. */
+
+splay_tree_node
+splay_tree_max (sp)
+ splay_tree sp;
+{
+ splay_tree_node n = sp->root;
+
+ if (!n)
+ return NULL;
+
+ while (n->right)
+ n = n->right;
+
+ return n;
+}
+
+/* Return the node in SP with the smallest key. */
+
+splay_tree_node
+splay_tree_min (sp)
+ splay_tree sp;
+{
+ splay_tree_node n = sp->root;
+
+ if (!n)
+ return NULL;
+
+ while (n->left)
+ n = n->left;
+
+ return n;
+}
+
/* Return the immediate predecessor KEY, or NULL if there is no
predecessor. KEY need not be present in the tree. */