00001 #ifdef DMALLOC
00002 #include <dmalloc.h>
00003 #endif
00004 #include "stack.h"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #define DEBUG_ASSERT 1
00024
00025 typedef struct rb_red_blk_node {
00026 void* key;
00027 void* info;
00028 int red;
00029 struct rb_red_blk_node* left;
00030 struct rb_red_blk_node* right;
00031 struct rb_red_blk_node* parent;
00032 } rb_red_blk_node;
00033
00034
00035
00036
00037 typedef struct rb_red_blk_tree {
00038 int (*Compare)(const void* a, const void* b);
00039 void (*DestroyKey)(void* a);
00040 void (*DestroyInfo)(void* a);
00041 void (*PrintKey)(const void* a);
00042 void (*PrintInfo)(void* a);
00043
00044
00045
00046
00047
00048
00049 rb_red_blk_node* root;
00050 rb_red_blk_node* nil;
00051 } rb_red_blk_tree;
00052
00053 rb_red_blk_tree* RBTreeCreate(int (*CompFunc)(const void*, const void*),
00054 void (*DestFunc)(void*),
00055 void (*InfoDestFunc)(void*),
00056 void (*PrintFunc)(const void*),
00057 void (*PrintInfo)(void*));
00058 rb_red_blk_node * RBTreeInsert(rb_red_blk_tree*, void* key, void* info);
00059 void RBTreePrint(rb_red_blk_tree*);
00060 void RBDelete(rb_red_blk_tree* , rb_red_blk_node* );
00061 void RBTreeDestroy(rb_red_blk_tree*);
00062 rb_red_blk_node* TreePredecessor(rb_red_blk_tree*,rb_red_blk_node*);
00063 rb_red_blk_node* TreeSuccessor(rb_red_blk_tree*,rb_red_blk_node*);
00064 rb_red_blk_node* RBExactQuery(rb_red_blk_tree*, void*);
00065 stk_stack * RBEnumerate(rb_red_blk_tree* tree,void* low, void* high);
00066 rb_red_blk_node* RBQueryLargestSmaller(rb_red_blk_tree* tree, void* q);
00067 void NullFunction(void*);