00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUCON_PRITREE_H
00019 #define CUCON_PRITREE_H
00020
00021 #include <cucon/fwd.h>
00022 #include <cu/clos.h>
00023 #include <stdio.h>
00024
00025 CU_BEGIN_DECLARATIONS
00026
00027
00028
00029
00030 struct cucon_pritree
00031 {
00032 cucon_prinode_t front;
00033 size_t size;
00034 };
00035
00036
00037
00038 struct cucon_prinode
00039 {
00040 double priority;
00041 cucon_prinode_t prior;
00042 cucon_prinode_t left;
00043 cucon_prinode_t right;
00044 };
00045
00046
00047 void cucon_pritree_init(cucon_pritree_t pritree);
00048
00049
00050 cucon_pritree_t cucon_pritree_new(void);
00051
00052
00053 #define cucon_pritree_front(pritree) \
00054 (CU_MARG(cucon_pritree_t, pritree)->front)
00055
00056
00057 #define cucon_pritree_is_empty(pritree) \
00058 (CU_MARG(cucon_pritree_t, pritree)->front==NULL)
00059
00060
00061 #define cucon_pritree_size(pritree) (CU_MARG(cucon_pritree_t, pritree)->size)
00062
00063
00064
00065 void cucon_pritree_pop(cucon_pritree_t pritree);
00066
00067
00068
00069 void cucon_pritree_insert_init(cucon_pritree_t pritree,
00070 cucon_prinode_t prinode,
00071 double priority);
00072
00073
00074 void cucon_pritree_erase(cucon_pritree_t pritree, cucon_prinode_t prinode);
00075
00076
00077 void cucon_pritree_change_priority(cucon_pritree_t pritree,
00078 cucon_prinode_t prinode,
00079 double priority);
00080
00081
00082 void cucon_pritree_add_to_all_priorities(cucon_pritree_t pritree, double delta);
00083
00084
00085 #define cucon_prinode_priority(prinode) \
00086 (CU_MARG(cucon_prinode_t, prinode)->priority)
00087
00088
00089
00090 cu_bool_t cucon_prinode_conj_down_to(cucon_prinode_t prinode,
00091 double min_priority,
00092 cu_clop(cb, cu_bool_t, cucon_prinode_t));
00093
00094
00095 void cucon_pritree_dump_priorities(cucon_pritree_t pritree, FILE *out);
00096
00097
00098 CU_END_DECLARATIONS
00099
00100 #endif