--- mstools/samples/rpc/dict/dict0.h 2018/08/09 18:20:59 1.1.1.2 +++ mstools/samples/rpc/dict/dict0.h 2018/08/09 18:24:22 1.1.1.3 @@ -9,17 +9,10 @@ /**************************************************************/ /* user interface header file for top down splay package */ /* based on Sleator & Tarjan's Self Adjusting Trees */ -/* Author: Dov Harel, 12/9/1988 */ -/* Modified to: */ -/* compact (space optimization) */ -/* return Dict_Status */ -/* changed interfaces */ -/* Dov Harel, 11/90 */ /**************************************************************/ -typedef - /* type of a comparison function */ - int (*cmp_rec_func)(void *, void *); +typedef int (*cmp_rec_func)(void *, void *); + /* type of a comparison function */ typedef struct tnode { struct tnode *left; /* left child pointer */ @@ -28,21 +21,19 @@ typedef struct tnode { } TreeNode; typedef struct dictnode { - TreeNode *root; /* pointer to the root of a SAT */ - long size; /* number of records in dictionary */ - void * state; /* reserved for state info */ - /* int (*cmp_rec)(void *, void *); comparison function pointer */ - cmp_rec_func cmp_rec; + TreeNode *root; /* pointer to the root of a SAT */ + long size; /* number of records in dictionary */ + void * state; /* reserved for state info */ + cmp_rec_func cmp_rec; /* pointer to a comparison function */ TreeNode* (*splay)(TreeNode *, void *, cmp_rec_func); - /* pointer to a splay function */ - void (*print_rec)(void *); /* one line print function */ + /* pointer to a splay function */ + void (*print_rec)(void *); /* one line print function */ } Dictionary; /*************************************************************************/ /***** Core functions (internal) *****/ /*************************************************************************/ - TreeNode * /* returns the new root */ tdSplay( /* general top down splay */ TreeNode *root, /* the current root of the tree */ @@ -85,12 +76,11 @@ typedef enum { LAST_ITEM, EMPTY_DICTIONARY, NULL_ITEM -} -Dict_Status; +} Dict_Status; -#define DICT_CURR_ITEM(pDict) ( (pDict)->root->item ) +#define DICT_CURR_ITEM(pDict) ( (pDict)->root->item ) -#define DICT_EMPTY(pDict) ( (pDict)->root == NULL ) +#define DICT_EMPTY(pDict) ( (pDict)->root == NULL ) Dictionary* Dict_New( /* returns a new dictionary node */