From e00bc6a7ba6342b27c657c0f59b27e06bd870346 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Mon, 7 May 2001 16:21:15 +0000 Subject: [PATCH] merge from gcc --- include/ChangeLog | 5 +++++ include/splay-tree.h | 4 ++++ libiberty/ChangeLog | 5 +++++ libiberty/splay-tree.c | 36 +++++++++++++++++++++++++++++++++++- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/include/ChangeLog b/include/ChangeLog index 5c48a648419..24fb134d902 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2001-05-07 Mark Mitchell + + * splay-tree.h (splay_tree_max): New function. + (splay_tree_min): Likewise. + 2001-04-27 Johan Rydberg * dis-asm.h (print_insn_openrisc): Add prototype. diff --git a/include/splay-tree.h b/include/splay-tree.h index e43d4b62eaa..37e9a35937f 100644 --- a/include/splay-tree.h +++ b/include/splay-tree.h @@ -110,6 +110,10 @@ extern splay_tree_node splay_tree_predecessor extern splay_tree_node splay_tree_successor PARAMS((splay_tree, splay_tree_key)); +extern splay_tree_node splay_tree_max + PARAMS((splay_tree)); +extern splay_tree_node splay_tree_min + PARAMS((splay_tree)); extern int splay_tree_foreach PARAMS((splay_tree, splay_tree_foreach_fn, void*)); diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 8494e573731..29f8856cb28 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2001-05-07 Mark Mitchell + + * splay-tree.h (splay_tree_max): New function. + (splay_tree_min): Likewise. + 2001-04-15 Daniel Berlin * 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. */ -- 2.30.2