Go to the documentation of this file.00001 #ifndef KBW_HEAP
00002 #define KBW_HEAP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019 #include "common.h"
00020 #include "collection.h"
00021
00022 #include <errno.h>
00023
00024 __BEGIN_DECLS
00025
00026 typedef CPROPS_DLL struct _heap
00027 {
00028 void **heap;
00029 unsigned int heap_height;
00030 unsigned int heap_end;
00031 unsigned int heap_length;
00032
00033 int mode;
00034 cp_compare_fn comp;
00035 cp_copy_fn copy;
00036 cp_destructor_fn dtr;
00037
00038 cp_mutex *lock;
00039 cp_thread txowner;
00040 } cp_heap;
00041
00042 #if defined(DEBUG) || defined(__TRACE__) || defined(_HEAP_TRACE)
00043 CPROPS_DLL
00044 void heap_info(cp_heap *h);
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054 CPROPS_DLL
00055 cp_heap *cp_heap_create(cp_compare_fn comp);
00056
00057 CPROPS_DLL
00058 cp_heap *cp_heap_create_by_option(int mode,
00059 int initial_size,
00060 cp_compare_fn comp,
00061 cp_copy_fn copy,
00062 cp_destructor_fn dtr);
00063
00064
00065 CPROPS_DLL
00066 int cp_heap_push(cp_heap *h, void *in);
00067
00068
00069 CPROPS_DLL
00070 void *cp_heap_peek(cp_heap *h);
00071
00072
00073 CPROPS_DLL
00074 void *cp_heap_pop(cp_heap *h);
00075
00076
00077 CPROPS_DLL
00078 int cp_heap_contract(cp_heap *h);
00079
00080
00081 CPROPS_DLL
00082 void cp_heap_destroy(cp_heap *h);
00083
00084
00085 CPROPS_DLL
00086 unsigned int cp_heap_count(cp_heap *h);
00087
00088
00089
00090
00091 CPROPS_DLL
00092 unsigned int cp_heap_size(cp_heap *h);
00093
00094 #ifdef DEBUG
00095 CPROPS_DLL
00096 int cp_heap_verify(cp_heap *h);
00097 #endif
00098
00099
00100 CPROPS_DLL
00101 void cp_heap_callback(cp_heap *h, cp_callback_fn cb, void *prm);
00102
00103
00104
00105
00106 CPROPS_DLL
00107 int cp_heap_lock(cp_heap *h);
00108
00109
00110 CPROPS_DLL
00111 int cp_heap_unlock(cp_heap *h);
00112
00113
00114 CPROPS_DLL
00115 int cp_heap_txlock(cp_heap *h);
00116
00117
00118 CPROPS_DLL
00119 int cp_heap_txunlock(cp_heap *h);
00120
00121
00122 CPROPS_DLL
00123 int cp_heap_get_mode(cp_heap *h);
00124
00125
00126 CPROPS_DLL
00127 int cp_heap_set_mode(cp_heap *h, int mode);
00128
00129
00130 CPROPS_DLL
00131 int cp_heap_unset_mode(cp_heap *h, int mode);
00132
00133 __END_DECLS
00134
00135
00136
00137 #endif