21 if( *(
int*)a > *(
int*)b)
return(1);
22 if( *(
int*)a < *(
int*)b)
return(-1);
35 printf(
"choose one of the following:\n");
36 printf(
"(1) add to tree\n(2) delete from tree\n(3) query\n");
37 printf(
"(4) find predecessor\n(5) find successor\n");
39 do option=fgetc(stdin);
while(-1 != option && isspace(option));
45 printf(
"type key for new node\n");
47 newInt=
malloc(
sizeof(
int));
55 printf(
"type key of node to remove\n");
58 else printf(
"key not found in tree, no action taken\n");
64 printf(
"type key of node to query for\n");
67 printf(
"data found in tree at location %i\n",(
int)
newNode);
69 printf(
"data not in tree\n");
75 printf(
"type key of node to find predecessor of\n");
80 printf(
"there is no predecessor for that node (it is a minimum)\n");
82 printf(
"predecessor has key %i\n",*(
int*)
newNode->key);
85 printf(
"data not in tree\n");
91 printf(
"type key of node to find successor of\n");
96 printf(
"there is no successor for that node (it is a maximum)\n");
98 printf(
"successor has key %i\n",*(
int*)
newNode->key);
101 printf(
"data not in tree\n");
112 printf(
"Invalid input; Please try again.\n");
static node_list * newNode(Grid *g, Agnode_t *n, node_list *nxt)
void RBDelete(rb_red_blk_tree *tree, rb_red_blk_node *z)
rb_red_blk_node * TreePredecessor(rb_red_blk_tree *tree, rb_red_blk_node *x)
void RBTreeDestroy(rb_red_blk_tree *tree)
rb_red_blk_node * RBExactQuery(rb_red_blk_tree *tree, void *q)
rb_red_blk_node * RBTreeInsert(rb_red_blk_tree *tree, void *key)
rb_red_blk_node * TreeSuccessor(rb_red_blk_tree *tree, rb_red_blk_node *x)
rb_red_blk_tree * RBTreeCreate(int(*CompFunc)(const void *, const void *), void(*DestFunc)(void *))
int IntComp(const void *a, const void *b)