Go to the documentation of this file.00001 #ifndef _CP_LINKEDLIST_H
00002 #define _CP_LINKEDLIST_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "common.h"
00012
00013 __BEGIN_DECLS
00014
00015 #include "config.h"
00016 #include "collection.h"
00017 #include "mempool.h"
00018
00019
00020
00021
00022
00023 typedef CPROPS_DLL struct _cp_list_entry
00024 {
00025 void *item;
00026 struct _cp_list_entry *next;
00027 struct _cp_list_entry *prev;
00028 } cp_list_entry;
00029
00030
00031
00032
00033 typedef CPROPS_DLL struct _cp_list
00034 {
00035 cp_list_entry *head;
00036 cp_list_entry *tail;
00037
00038 cp_compare_fn compare_fn;
00039 cp_copy_fn copy_fn;
00040 cp_destructor_fn free_fn;
00041
00042 int mode;
00043 cp_thread txowner;
00044
00045 long items;
00046
00047 int is_view;
00048 cp_lock *lock;
00049 int txtype;
00050
00051 cp_mempool *mempool;
00052 } cp_list;
00053
00054
00055
00056
00057 typedef CPROPS_DLL struct _cp_list_iterator
00058 {
00059 cp_list *list;
00060 cp_list_entry **pos;
00061
00062 int lock_type;
00063 } cp_list_iterator;
00064
00065
00066
00067 CPROPS_DLL
00068 cp_list *cp_list_create();
00069
00070 CPROPS_DLL
00071 cp_list *cp_list_create_nosync();
00072
00073
00074
00075
00076
00077
00078
00079
00080 CPROPS_DLL
00081 cp_list *cp_list_create_list(int mode,
00082 cp_compare_fn compare_fn,
00083 cp_copy_fn copy_fn,
00084 cp_destructor_fn item_destructor);
00085
00086 CPROPS_DLL
00087 cp_list *cp_list_create_view(int mode,
00088 cp_compare_fn compare_fn,
00089 cp_copy_fn copy_fn,
00090 cp_destructor_fn item_destructor,
00091 cp_lock *lock);
00092
00093
00094
00095
00096 CPROPS_DLL
00097 void cp_list_destroy(cp_list *);
00098
00099
00100
00101
00102 CPROPS_DLL
00103 void cp_list_destroy_by_option(cp_list *list, int option);
00104
00105
00106
00107
00108
00109 CPROPS_DLL
00110 void cp_list_destroy_custom(cp_list *list, cp_destructor_fn fn);
00111
00112
00113
00114
00115
00116 CPROPS_DLL
00117 void *cp_list_insert(cp_list *list, void *item);
00118
00119
00120
00121
00122
00123 CPROPS_DLL
00124 void *cp_list_remove(cp_list *list, void *item);
00125
00126
00127
00128
00129 CPROPS_DLL
00130 void *cp_list_insert_after(cp_list *list, void *item, void *existing);
00131
00132
00133
00134
00135 CPROPS_DLL
00136 void *cp_list_insert_before(cp_list *list, void *item, void *existing);
00137
00138
00139
00140
00141 CPROPS_DLL
00142 void *cp_list_search(cp_list *list, void *item);
00143
00144
00145
00146
00147
00148 CPROPS_DLL
00149 int cp_list_callback(cp_list *l, int (*item_action)(void *, void *), void *id);
00150
00151
00152
00153
00154
00155
00156
00157 CPROPS_DLL
00158 void *cp_list_append(cp_list *list, void *item);
00159
00160
00161
00162
00163 CPROPS_DLL
00164 void *cp_list_get_head(cp_list *list);
00165
00166
00167
00168
00169 CPROPS_DLL
00170 void *cp_list_get_tail(cp_list *list);
00171
00172
00173
00174
00175
00176
00177 CPROPS_DLL
00178 void *cp_list_remove_head(cp_list *list);
00179
00180
00181
00182
00183
00184
00185 CPROPS_DLL
00186 void *cp_list_remove_tail(cp_list *list);
00187
00188
00189
00190
00191
00192
00193
00194 CPROPS_DLL
00195 int cp_list_is_empty(cp_list *list);
00196
00197
00198
00199
00200
00201
00202
00203 CPROPS_DLL
00204 long cp_list_item_count(cp_list *);
00205
00206
00207
00208
00209
00210
00211 CPROPS_DLL
00212 int cp_list_lock(cp_list *list, int mode);
00213
00214
00215
00216
00217 #define cp_list_rdlock(list) cp_list_lock(list, COLLECTION_LOCK_READ)
00218
00219
00220
00221
00222 #define cp_list_wrlock(list) cp_list_lock(list, COLLECTION_LOCK_WRITE)
00223
00224
00225
00226
00227 CPROPS_DLL
00228 int cp_list_unlock(cp_list *list);
00229
00230
00231 CPROPS_DLL
00232 int cp_list_use_mempool(cp_list *list, cp_mempool *pool);
00233
00234
00235 CPROPS_DLL
00236 int cp_list_share_mempool(cp_list *list, cp_shared_mempool *pool);
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 CPROPS_DLL
00252 int cp_list_iterator_init(cp_list_iterator *iterator, cp_list *list, int lock_mode);
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 CPROPS_DLL
00267 int cp_list_iterator_init_tail(cp_list_iterator *iterator, cp_list *list, int lock_mode);
00268
00269
00270
00271
00272
00273
00274
00275
00276 CPROPS_DLL
00277 cp_list_iterator* cp_list_create_iterator(cp_list *list, int lock_mode);
00278
00279
00280
00281
00282 CPROPS_DLL
00283 int cp_list_iterator_head(cp_list_iterator *iterator);
00284
00285
00286
00287
00288 CPROPS_DLL
00289 int cp_list_iterator_tail(cp_list_iterator *iterator);
00290
00291 CPROPS_DLL
00292 int cp_list_iterator_destroy(cp_list_iterator *iterator);
00293
00294
00295
00296
00297 CPROPS_DLL
00298 int cp_list_iterator_release(cp_list_iterator *iterator);
00299
00300
00301
00302
00303
00304
00305
00306 CPROPS_DLL
00307 void *cp_list_iterator_next(cp_list_iterator *iterator);
00308
00309
00310
00311
00312
00313
00314
00315 CPROPS_DLL
00316 void *cp_list_iterator_prev(cp_list_iterator *iterator);
00317
00318
00319
00320
00321
00322
00323
00324 CPROPS_DLL
00325 void *cp_list_iterator_curr(cp_list_iterator *iterator);
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 CPROPS_DLL
00337 void *cp_list_iterator_insert(cp_list_iterator *iterator, void *item);
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 CPROPS_DLL
00348 void *cp_list_iterator_append(cp_list_iterator *iterator, void *item);
00349
00350
00351
00352
00353
00354
00355
00356
00357 CPROPS_DLL
00358 void *cp_list_iterator_remove(cp_list_iterator *iterator);
00359
00360 __END_DECLS
00361
00362
00363
00364 #endif