linked_list.h

Go to the documentation of this file.
00001 #ifndef _CP_LINKEDLIST_H
00002 #define _CP_LINKEDLIST_H
00003 
00011 #include "common.h"
00012 
00013 __BEGIN_DECLS
00014 
00015 #include "config.h"
00016 #include "collection.h"
00017 #include "mempool.h"
00018 
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 
00033 typedef CPROPS_DLL struct _cp_list
00034 {
00035     cp_list_entry *head;        
00036     cp_list_entry *tail;        
00038     cp_compare_fn compare_fn;   
00039     cp_copy_fn copy_fn;         
00040     cp_destructor_fn free_fn;   
00042     int mode;                   
00043     cp_thread txowner;          
00045     long items;                 
00047     int is_view;                
00048     cp_lock *lock;              
00049     int txtype;                 
00051     cp_mempool *mempool;        
00052 } cp_list;
00053 
00057 typedef CPROPS_DLL struct _cp_list_iterator
00058 {
00059     cp_list *list;           
00060     cp_list_entry **pos;     
00062     int lock_type;           
00063 } cp_list_iterator;
00064 
00065 
00067 CPROPS_DLL 
00068 cp_list *cp_list_create();
00069 
00070 CPROPS_DLL 
00071 cp_list *cp_list_create_nosync();
00072 
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 
00096 CPROPS_DLL 
00097 void cp_list_destroy(cp_list *);
00098 
00102 CPROPS_DLL 
00103 void cp_list_destroy_by_option(cp_list *list, int option);
00104 
00109 CPROPS_DLL 
00110 void cp_list_destroy_custom(cp_list *list, cp_destructor_fn fn);
00111 
00116 CPROPS_DLL 
00117 void *cp_list_insert(cp_list *list, void *item);
00118 
00123 CPROPS_DLL 
00124 void *cp_list_remove(cp_list *list, void *item);
00125 
00129 CPROPS_DLL 
00130 void *cp_list_insert_after(cp_list *list, void *item, void *existing);
00131 
00135 CPROPS_DLL 
00136 void *cp_list_insert_before(cp_list *list, void *item, void *existing);
00137 
00141 CPROPS_DLL 
00142 void *cp_list_search(cp_list *list, void *item);
00143 
00148 CPROPS_DLL 
00149 int cp_list_callback(cp_list *l, int (*item_action)(void *, void *), void *id);
00150 
00157 CPROPS_DLL 
00158 void *cp_list_append(cp_list *list, void *item);
00159 
00163 CPROPS_DLL 
00164 void *cp_list_get_head(cp_list *list);
00165 
00169 CPROPS_DLL 
00170 void *cp_list_get_tail(cp_list *list);
00171 
00177 CPROPS_DLL 
00178 void *cp_list_remove_head(cp_list *list);
00179 
00185 CPROPS_DLL 
00186 void *cp_list_remove_tail(cp_list *list);
00187 
00194 CPROPS_DLL 
00195 int cp_list_is_empty(cp_list *list);
00196 
00203 CPROPS_DLL 
00204 long cp_list_item_count(cp_list *);
00205 
00211 CPROPS_DLL 
00212 int cp_list_lock(cp_list *list, int mode);
00213 
00217 #define cp_list_rdlock(list) cp_list_lock(list, COLLECTION_LOCK_READ)
00218 
00222 #define cp_list_wrlock(list) cp_list_lock(list, COLLECTION_LOCK_WRITE)
00223 
00227 CPROPS_DLL 
00228 int cp_list_unlock(cp_list *list);
00229     
00230 /* set list to use given mempool or allocate a new one if pool is NULL */
00231 CPROPS_DLL
00232 int cp_list_use_mempool(cp_list *list, cp_mempool *pool);
00233 
00234 /* set list to use a shared memory pool */
00235 CPROPS_DLL
00236 int cp_list_share_mempool(cp_list *list, cp_shared_mempool *pool);
00237 
00238 
00251 CPROPS_DLL 
00252 int cp_list_iterator_init(cp_list_iterator *iterator, cp_list *list, int lock_mode);
00253 
00266 CPROPS_DLL 
00267 int cp_list_iterator_init_tail(cp_list_iterator *iterator, cp_list *list, int lock_mode);
00268 
00276 CPROPS_DLL 
00277 cp_list_iterator* cp_list_create_iterator(cp_list *list, int lock_mode);
00278 
00282 CPROPS_DLL 
00283 int cp_list_iterator_head(cp_list_iterator *iterator);
00284 
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 
00297 CPROPS_DLL 
00298 int cp_list_iterator_release(cp_list_iterator *iterator);
00299 
00306 CPROPS_DLL 
00307 void *cp_list_iterator_next(cp_list_iterator *iterator);
00308 
00315 CPROPS_DLL 
00316 void *cp_list_iterator_prev(cp_list_iterator *iterator);
00317 
00324 CPROPS_DLL 
00325 void *cp_list_iterator_curr(cp_list_iterator *iterator);
00326 
00327 
00336 CPROPS_DLL 
00337 void *cp_list_iterator_insert(cp_list_iterator *iterator, void *item);
00338 
00347 CPROPS_DLL 
00348 void *cp_list_iterator_append(cp_list_iterator *iterator, void *item);
00349 
00357 CPROPS_DLL 
00358 void *cp_list_iterator_remove(cp_list_iterator *iterator);
00359 
00360 __END_DECLS
00361 
00364 #endif

Generated on Mon Dec 5 23:00:22 2011 for cprops by  doxygen 1.4.7