| 1 | /* splay-tree.h,v 1.2 2004/09/14 22:27:35 bird Exp */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * GNU, -liberty.
|
|---|
| 4 | */
|
|---|
| 5 | /* A splay-tree datatype.
|
|---|
| 6 | Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
|
|---|
| 7 | Contributed by Mark Mitchell ([email protected]).
|
|---|
| 8 |
|
|---|
| 9 | This file is part of GCC.
|
|---|
| 10 |
|
|---|
| 11 | GCC is free software; you can redistribute it and/or modify it
|
|---|
| 12 | under the terms of the GNU General Public License as published by
|
|---|
| 13 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 14 | any later version.
|
|---|
| 15 |
|
|---|
| 16 | GCC is distributed in the hope that it will be useful, but
|
|---|
| 17 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 19 | General Public License for more details.
|
|---|
| 20 |
|
|---|
| 21 | You should have received a copy of the GNU General Public License
|
|---|
| 22 | along with GCC; see the file COPYING. If not, write to
|
|---|
| 23 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
|---|
| 24 | Boston, MA 02111-1307, USA. */
|
|---|
| 25 |
|
|---|
| 26 | /* For an easily readable description of splay-trees, see:
|
|---|
| 27 |
|
|---|
| 28 | Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
|
|---|
| 29 | Algorithms. Harper-Collins, Inc. 1991.
|
|---|
| 30 |
|
|---|
| 31 | The major feature of splay trees is that all basic tree operations
|
|---|
| 32 | are amortized O(log n) time for a tree with n nodes. */
|
|---|
| 33 |
|
|---|
| 34 | #ifndef _SPLAY_TREE_H
|
|---|
| 35 | #define _SPLAY_TREE_H
|
|---|
| 36 |
|
|---|
| 37 | #ifdef __cplusplus
|
|---|
| 38 | extern "C" {
|
|---|
| 39 | #endif /* __cplusplus */
|
|---|
| 40 |
|
|---|
| 41 | #include <ansidecl.h>
|
|---|
| 42 |
|
|---|
| 43 | /* Use typedefs for the key and data types to facilitate changing
|
|---|
| 44 | these types, if necessary. These types should be sufficiently wide
|
|---|
| 45 | that any pointer or scalar can be cast to these types, and then
|
|---|
| 46 | cast back, without loss of precision. */
|
|---|
| 47 | typedef unsigned long int splay_tree_key;
|
|---|
| 48 | typedef unsigned long int splay_tree_value;
|
|---|
| 49 |
|
|---|
| 50 | /* Forward declaration for a node in the tree. */
|
|---|
| 51 | typedef struct splay_tree_node_s *splay_tree_node;
|
|---|
| 52 |
|
|---|
| 53 | /* The type of a function which compares two splay-tree keys. The
|
|---|
| 54 | function should return values as for qsort. */
|
|---|
| 55 | typedef int (*splay_tree_compare_fn) PARAMS((splay_tree_key, splay_tree_key));
|
|---|
| 56 |
|
|---|
| 57 | /* The type of a function used to deallocate any resources associated
|
|---|
| 58 | with the key. */
|
|---|
| 59 | typedef void (*splay_tree_delete_key_fn) PARAMS((splay_tree_key));
|
|---|
| 60 |
|
|---|
| 61 | /* The type of a function used to deallocate any resources associated
|
|---|
| 62 | with the value. */
|
|---|
| 63 | typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value));
|
|---|
| 64 |
|
|---|
| 65 | /* The type of a function used to iterate over the tree. */
|
|---|
| 66 | typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*));
|
|---|
| 67 |
|
|---|
|
|---|