20#ifndef GCC_TYPED_SPLAY_TREE_H
21#define GCC_TYPED_SPLAY_TREE_H
24template <
typename KEY_TYPE,
typename VALUE_TYPE>
109template <
typename KEY_TYPE,
typename VALUE_TYPE>
112 delete_key_fn delete_key_fn,
113 delete_value_fn delete_value_fn)
117 delete_key = delete_key_fn;
118 delete_value = delete_value_fn;
123template <
typename KEY_TYPE,
typename VALUE_TYPE>
127 splay_tree_delete_helper (root);
133template <
typename KEY_TYPE,
typename VALUE_TYPE>
138 return node_to_value (node);
144template <
typename KEY_TYPE,
typename VALUE_TYPE>
149 return node_to_value (node);
155template <
typename KEY_TYPE,
typename VALUE_TYPE>
160 return node_to_value (node);
167template <
typename KEY_TYPE,
typename VALUE_TYPE>
172 splay_tree_insert (key, value);
177template <
typename KEY_TYPE,
typename VALUE_TYPE>
181 splay_tree_remove (key);
186template <
typename KEY_TYPE,
typename VALUE_TYPE>
190 return node_to_value (splay_tree_max ());
195template <
typename KEY_TYPE,
typename VALUE_TYPE>
199 return node_to_value (splay_tree_min ());
207template <
typename KEY_TYPE,
typename VALUE_TYPE>
212 return splay_tree_foreach_helper (root, foreach_fn, user_data);
217template <
typename KEY_TYPE,
typename VALUE_TYPE>
227template <
typename KEY_TYPE,
typename VALUE_TYPE>
235template <
typename KEY_TYPE,
typename VALUE_TYPE>
245template <
typename KEY_TYPE,
typename VALUE_TYPE>
260 node->
back = pending;
283 pending = active->
left;
290 pending = active->
right;
303template <
typename KEY_TYPE,
typename VALUE_TYPE>
319template <
typename KEY_TYPE,
typename VALUE_TYPE>
334template <
typename KEY_TYPE,
typename VALUE_TYPE>
362 cmp2 = (*comp) (key, c->
key);
364 || (cmp2 < 0 && !c->left)
365 || (cmp2 > 0 && !c->
right))
368 rotate_left (&root, n, c);
370 rotate_right (&root, n, c);
375 if (
cmp1 < 0 && cmp2 < 0)
378 rotate_left (&root, n, n->
left);
380 else if (
cmp1 > 0 && cmp2 > 0)
383 rotate_right (&root, n, n->
right);
388 rotate_left (&root, n, n->
left);
390 else if (
cmp1 > 0 && cmp2 < 0)
393 rotate_right (&root, n, n->
right);
403template <
typename KEY_TYPE,
typename VALUE_TYPE>
407 foreach_fn fn,
void *
data)
448template <
typename KEY_TYPE,
typename VALUE_TYPE>
456 splay_tree_splay (key);
500template <
typename KEY_TYPE,
typename VALUE_TYPE>
504 splay_tree_splay (key);
506 if (root && (*
comp) (root->key, key) == 0)
540template <
typename KEY_TYPE,
typename VALUE_TYPE>
544 splay_tree_splay (key);
546 if (root && (*
comp)(root->key, key) == 0)
554template <
typename KEY_TYPE,
typename VALUE_TYPE>
571template <
typename KEY_TYPE,
typename VALUE_TYPE>
589template <
typename KEY_TYPE,
typename VALUE_TYPE>
603 splay_tree_splay (key);
622template <
typename KEY_TYPE,
typename VALUE_TYPE>
636 splay_tree_splay (key);
Definition genoutput.cc:150
Definition edit-context.cc:65
Definition typed-splay-tree.h:26
void(*) delete_key_fn(key_type)
Definition typed-splay-tree.h:32
delete_value_fn delete_value
Definition typed-splay-tree.h:104
value_type predecessor(key_type k)
Definition typed-splay-tree.h:146
value_type min()
Definition typed-splay-tree.h:197
~typed_splay_tree()
Definition typed-splay-tree.h:125
value_type max()
Definition typed-splay-tree.h:188
void remove(key_type k)
Definition typed-splay-tree.h:179
key_type splay_tree_key
Definition typed-splay-tree.h:55
typed_splay_tree(compare_fn, delete_key_fn, delete_value_fn)
Definition typed-splay-tree.h:111
value_type successor(key_type k)
Definition typed-splay-tree.h:157
typed_splay_tree(const typed_splay_tree &)
int(*) foreach_fn(key_type, value_type, void *)
Definition typed-splay-tree.h:34
static void rotate_left(splay_tree_node *, splay_tree_node, splay_tree_node)
Definition typed-splay-tree.h:305
void splay_tree_splay(splay_tree_key)
Definition typed-splay-tree.h:336
KEY_TYPE key_type
Definition typed-splay-tree.h:28
void KDEL(splay_tree_key)
Definition typed-splay-tree.h:229
splay_tree_node splay_tree_max()
Definition typed-splay-tree.h:556
splay_tree_node splay_tree_min()
Definition typed-splay-tree.h:573
value_type lookup(key_type k)
Definition typed-splay-tree.h:135
void splay_tree_remove(splay_tree_key key)
Definition typed-splay-tree.h:502
splay_tree_node splay_tree_successor(splay_tree_key)
Definition typed-splay-tree.h:625
static void rotate_right(splay_tree_node *, splay_tree_node, splay_tree_node)
Definition typed-splay-tree.h:321
void VDEL(splay_tree_value)
Definition typed-splay-tree.h:237
splay_tree_node_s * splay_tree_node
Definition typed-splay-tree.h:72
void insert(key_type k, value_type v)
Definition typed-splay-tree.h:169
compare_fn comp
Definition typed-splay-tree.h:98
VALUE_TYPE value_type
Definition typed-splay-tree.h:29
splay_tree_node splay_tree_lookup(splay_tree_key key)
Definition typed-splay-tree.h:542
int(*) compare_fn(key_type, key_type)
Definition typed-splay-tree.h:31
int foreach(foreach_fn, void *)
Definition typed-splay-tree.h:209
void(*) delete_value_fn(value_type)
Definition typed-splay-tree.h:33
splay_tree_node splay_tree_predecessor(splay_tree_key)
Definition typed-splay-tree.h:592
splay_tree_node splay_tree_insert(splay_tree_key, splay_tree_value)
Definition typed-splay-tree.h:450
typed_splay_tree & operator=(const typed_splay_tree &)
delete_key_fn delete_key
Definition typed-splay-tree.h:101
splay_tree_node root
Definition typed-splay-tree.h:95
void splay_tree_delete_helper(splay_tree_node)
Definition typed-splay-tree.h:248
static value_type node_to_value(splay_tree_node node)
Definition typed-splay-tree.h:219
value_type splay_tree_value
Definition typed-splay-tree.h:56
static int splay_tree_foreach_helper(splay_tree_node, foreach_fn, void *)
Definition typed-splay-tree.h:405
static sbitmap * comp
Definition gcse.cc:1639
static noinline intptr_t cmp1(char *e0, char *e1, sort_ctx *c)
Definition sort.cc:148
Definition compare-elim.cc:91
Definition typed-splay-tree.h:59
splay_tree_value value
Definition typed-splay-tree.h:64
splay_tree_node_s * left
Definition typed-splay-tree.h:67
splay_tree_key key
Definition typed-splay-tree.h:61
splay_tree_node_s * right
Definition typed-splay-tree.h:67
splay_tree_node_s * back
Definition typed-splay-tree.h:70
#define NULL
Definition system.h:50