00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #ifndef PLANG_RBTREE_PRIV_H
00021 #define PLANG_RBTREE_PRIV_H
00022 
00023 #include "term-priv.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00031 struct p_rbnode
00032 {
00033 #if defined(P_TERM_64BIT)
00034     unsigned int type : 31;
00035     unsigned int red  : 1;
00036     unsigned int size;
00037 #else
00038     unsigned int type : 7;
00039     unsigned int red  : 1;
00040     unsigned int size : 24;
00041 #endif
00042     const p_term *name;
00043     union {
00044         p_term *value;
00045         struct p_term_clause_list clauses;
00046     };
00047     p_rbnode *parent;
00048     p_rbnode *left;
00049     p_rbnode *right;
00050 };
00051 
00052 typedef struct p_rbkey p_rbkey;
00053 struct p_rbkey
00054 {
00055     unsigned int type;
00056     unsigned int size;
00057     const p_term *name;
00058 };
00059 
00060 int _p_rbkey_init(p_rbkey *key, const p_term *term);
00061 int _p_rbkey_compare_keys(const p_rbkey *key1, const p_rbkey *key2);
00062 
00063 void _p_rbtree_init(p_rbtree *tree);
00064 void _p_rbtree_free(p_rbtree *tree);
00065 
00066 p_rbnode *_p_rbtree_lookup(const p_rbtree *tree, const p_rbkey *key);
00067 p_rbnode *_p_rbtree_insert(p_rbtree *tree, const p_rbkey *key);
00068 p_term *_p_rbtree_remove(p_rbtree *tree, const p_rbkey *key);
00069 
00070 p_rbnode *_p_rbtree_visit_all(p_rbtree *tree, p_rbnode *last);
00071 
00074 #ifdef __cplusplus
00075 };
00076 #endif
00077 
00078 #endif