36 |
|
|
37 |
#include "ansidecl.h" |
#include "ansidecl.h" |
38 |
|
|
39 |
|
#ifndef GTY |
40 |
|
#define GTY(X) |
41 |
|
#endif |
42 |
|
|
43 |
/* Use typedefs for the key and data types to facilitate changing |
/* Use typedefs for the key and data types to facilitate changing |
44 |
these types, if necessary. These types should be sufficiently wide |
these types, if necessary. These types should be sufficiently wide |
45 |
that any pointer or scalar can be cast to these types, and then |
that any pointer or scalar can be cast to these types, and then |
69 |
node structures. The first argument is the number of bytes needed; |
node structures. The first argument is the number of bytes needed; |
70 |
the second is a data pointer the splay tree functions pass through |
the second is a data pointer the splay tree functions pass through |
71 |
to the allocator. This function must never return zero. */ |
to the allocator. This function must never return zero. */ |
72 |
typedef void *(*splay_tree_allocate_fn) PARAMS((int, void *)); |
typedef PTR (*splay_tree_allocate_fn) PARAMS((int, void *)); |
73 |
|
|
74 |
/* The type of a function used to free memory allocated using the |
/* The type of a function used to free memory allocated using the |
75 |
corresponding splay_tree_allocate_fn. The first argument is the |
corresponding splay_tree_allocate_fn. The first argument is the |
78 |
typedef void (*splay_tree_deallocate_fn) PARAMS((void *, void *)); |
typedef void (*splay_tree_deallocate_fn) PARAMS((void *, void *)); |
79 |
|
|
80 |
/* The nodes in the splay tree. */ |
/* The nodes in the splay tree. */ |
81 |
struct splay_tree_node_s |
struct splay_tree_node_s GTY(()) |
82 |
{ |
{ |
83 |
/* The key. */ |
/* The key. */ |
84 |
splay_tree_key key; |
splay_tree_key GTY ((use_param1)) key; |
85 |
|
|
86 |
/* The value. */ |
/* The value. */ |
87 |
splay_tree_value value; |
splay_tree_value GTY ((use_param2)) value; |
88 |
|
|
89 |
/* The left and right children, respectively. */ |
/* The left and right children, respectively. */ |
90 |
splay_tree_node left; |
splay_tree_node GTY ((use_params)) left; |
91 |
splay_tree_node right; |
splay_tree_node GTY ((use_params)) right; |
92 |
}; |
}; |
93 |
|
|
94 |
/* The splay tree itself. */ |
/* The splay tree itself. */ |
95 |
typedef struct splay_tree_s |
struct splay_tree_s GTY(()) |
96 |
{ |
{ |
97 |
/* The root of the tree. */ |
/* The root of the tree. */ |
98 |
splay_tree_node root; |
splay_tree_node GTY ((use_params)) root; |
99 |
|
|
100 |
/* The comparision function. */ |
/* The comparision function. */ |
101 |
splay_tree_compare_fn comp; |
splay_tree_compare_fn comp; |
109 |
/* Allocate/free functions, and a data pointer to pass to them. */ |
/* Allocate/free functions, and a data pointer to pass to them. */ |
110 |
splay_tree_allocate_fn allocate; |
splay_tree_allocate_fn allocate; |
111 |
splay_tree_deallocate_fn deallocate; |
splay_tree_deallocate_fn deallocate; |
112 |
void *allocate_data; |
PTR GTY((skip)) allocate_data; |
113 |
|
|
114 |
} *splay_tree; |
}; |
115 |
|
typedef struct splay_tree_s *splay_tree; |
116 |
|
|
117 |
extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn, |
extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn, |
118 |
splay_tree_delete_key_fn, |
splay_tree_delete_key_fn, |