Charades
avl_tree.h
1 #include "event.h"
2 #include "typedefs.h"
3 
4 /* Copied and modified from http://pine.cs.yale.edu/pinewiki/C/AvlTree google cache */
5 /* implementation of an AVL tree with explicit heights */
6 
7 struct avlNode {
8  struct avlNode *child[2]; /* left and right */
9  Event *key;
10  struct avlNode *next; /* for ROSS weird linked-list memory */
11  int height;
12  /* Enabling the padding should be tested */
13  //int padding[7];
14 };
15 
16 /* empty avl tree is just a null pointer */
17 
18 #define AVL_EMPTY (0)
19 
20 /* free a tree */
21 void avlDestroy(AvlTree t);
22 
23 /* return the height of a tree */
24 int avlGetHeight(AvlTree t);
25 
26 /* return nonzero if key is present in tree */
27 int avlSearch(AvlTree t, Event *key);
28 
29 /* insert a new element into a tree */
30 /* note *t is actual tree */
31 void avlInsert(AvlTree *t, Event *key);
32 
33 /* run sanity checks on tree (for debugging) */
34 /* assert will fail if heights are wrong */
35 void avlSanityCheck(AvlTree t);
36 
37 /* print all keys of the tree in order */
38 void avlPrintKeys(AvlTree t);
39 
40 /* delete and return minimum value in a tree */
41 Event * avlDeleteMin(AvlTree *t);
42 
43 Event * avlDelete(AvlTree *t, Event *key);
44 
45 Event * avlInsertOrDelete(AvlTree *t, Event *key);
46 
47 AvlTree avl_alloc(void);
48 
49 void avl_free(AvlTree t);
Definition: event.h:120
Definition: avl_tree.h:7
Declares most types used within the simulator and by models.