aboutsummaryrefslogtreecommitdiff
path: root/libiberty/splay-tree.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2001-05-07 16:21:15 +0000
committerDJ Delorie <dj@redhat.com>2001-05-07 16:21:15 +0000
commite00bc6a7ba6342b27c657c0f59b27e06bd870346 (patch)
tree5faa9326ee9ebc6e30a46051ceaebc9f3114f7b1 /libiberty/splay-tree.c
parent2d4a16222b642c4939bb74a9d80e0c970cac44d4 (diff)
downloadgdb-e00bc6a7ba6342b27c657c0f59b27e06bd870346.zip
gdb-e00bc6a7ba6342b27c657c0f59b27e06bd870346.tar.gz
gdb-e00bc6a7ba6342b27c657c0f59b27e06bd870346.tar.bz2
merge from gcc
Diffstat (limited to 'libiberty/splay-tree.c')
-rw-r--r--libiberty/splay-tree.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index 52b57c0..a712395 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. */