Cp_list


Files

file  linked_list.c

Functions

int cp_list_txlock (cp_list *list, int type)
int cp_list_txunlock (cp_list *list)
cp_listcp_list_create_internal (int mode, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor, int is_view)
cp_listcp_list_create ()
cp_listcp_list_create_nosync ()
cp_listcp_list_create_list (int mode, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor)
cp_listcp_list_create_view (int mode, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor, cp_lock *lock)
void cp_list_destroy_internal (cp_list *list, cp_destructor_fn fn, int mode)
void cp_list_destroy (cp_list *list)
void cp_list_destroy_by_option (cp_list *list, int option)
void cp_list_destroy_custom (cp_list *list, cp_destructor_fn fn)
long cp_list_item_count (cp_list *list)
void * cp_list_insert (cp_list *list, void *item)
void * cp_list_remove (cp_list *list, void *item)
void * cp_list_insert_after (cp_list *list, void *item, void *existing)
void * cp_list_insert_before (cp_list *list, void *item, void *existing)
void * cp_list_search (cp_list *list, void *item)
int cp_list_callback (cp_list *l, int(*item_action)(void *, void *), void *id)
void * cp_list_append (cp_list *list, void *item)
void * cp_list_get_head (cp_list *list)
void * cp_list_get_tail (cp_list *list)
void * cp_list_remove_head (cp_list *list)
void * cp_list_remove_tail (cp_list *list)
int cp_list_is_empty (cp_list *list)
int cp_list_lock_internal (cp_list *list, int mode)
int cp_list_unlock_internal (cp_list *list)
int cp_list_lock (cp_list *list, int type)
int cp_list_unlock (cp_list *list)
int cp_list_get_mode (cp_list *list)
int cp_list_set_mode (cp_list *list, int mode)
int cp_list_unset_mode (cp_list *list, int mode)
int cp_list_use_mempool (cp_list *list, cp_mempool *pool)
int cp_list_share_mempool (cp_list *list, cp_shared_mempool *pool)
cp_list_iteratorcp_list_create_iterator (cp_list *list, int type)
int cp_list_iterator_init (cp_list_iterator *iterator, cp_list *list, int type)
int cp_list_iterator_head (cp_list_iterator *iterator)
int cp_list_iterator_tail (cp_list_iterator *iterator)
int cp_list_iterator_init_tail (cp_list_iterator *iterator, cp_list *list, int type)
int cp_list_iterator_release (cp_list_iterator *iterator)
int cp_list_iterator_destroy (cp_list_iterator *iterator)
void * cp_list_iterator_next (cp_list_iterator *iterator)
void * cp_list_iterator_prev (cp_list_iterator *iterator)
void * cp_list_iterator_curr (cp_list_iterator *iterator)
void * cp_list_iterator_insert (cp_list_iterator *iterator, void *item)
void * cp_list_iterator_append (cp_list_iterator *iterator, void *item)
void * cp_list_iterator_remove (cp_list_iterator *iterator)

Function Documentation

void* cp_list_append ( cp_list list,
void *  item 
)

Append the element at the end of the list.

Return values:
item the appended item.
existing_item if multiple values not allowed and an equal item already exists.

Definition at line 402 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_db_connection_pool_create(), cp_db_register_dbms(), cp_result_set_next(), cp_thread_pool_create(), and lookup_internal().

int cp_list_callback ( cp_list l,
int(*)(void *, void *)  item_action,
void *  id 
)

run a callback on each item. Stops if the callback function returns non-zero.

Definition at line 385 of file linked_list.c.

References COLLECTION_LOCK_READ, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

cp_list* cp_list_create (  ) 

Default constructor

Definition at line 115 of file linked_list.c.

References COLLECTION_MODE_MULTIPLE_VALUES, and cp_list_create_internal().

Referenced by cp_db_init(), cp_result_set_autodispose(), and cp_thread_pool_create().

cp_list_iterator* cp_list_create_iterator ( cp_list list,
int  lock_mode 
)

create a new iterator and initialize it at the beginning of the list.

Parameters:
list the list to iterate over
lock_mode locking mode to use
Returns:
new iterator object

Definition at line 716 of file linked_list.c.

References cp_list_txlock(), and _cp_list_iterator::list.

Referenced by cp_thread_pool_stop().

cp_list* cp_list_create_list ( int  mode,
cp_compare_fn  compare_fn,
cp_copy_fn  copy_fn,
cp_destructor_fn  item_destructor 
)

Constructor

Parameters:
mode operation mode bitmap (see collection.h)
compare_fn compare method
copy_fn copy method

Definition at line 130 of file linked_list.c.

References cp_list_create_internal().

Referenced by cp_db_connection_pool_create(), cp_http_thread_fn(), and cp_priority_list_create_by_option().

void cp_list_destroy ( cp_list  ) 

Destroy the object with the mode stored in the list.

Definition at line 199 of file linked_list.c.

References cp_list_destroy_internal().

Referenced by cp_db_connection_pool_destroy(), cp_hashlist_iterator_to_key(), cp_hashtable_contains(), cp_result_set_destroy(), and cp_thread_pool_destroy().

void cp_list_destroy_by_option ( cp_list list,
int  option 
)

Destroy the object with the specified mode (override default).

Definition at line 204 of file linked_list.c.

References cp_list_destroy_internal().

Referenced by cp_priority_list_destroy_by_option().

void cp_list_destroy_custom ( cp_list list,
cp_destructor_fn  fn 
)

Destroy the object and all contained elements. For each element the method cp_destructor_fn is called.

Definition at line 209 of file linked_list.c.

References COLLECTION_MODE_DEEP, and cp_list_destroy_internal().

Referenced by cp_db_shutdown(), cp_http_thread_fn(), and cp_thread_pool_create().

void* cp_list_get_head ( cp_list list  ) 

Returns the first element of the list.

Definition at line 427 of file linked_list.c.

References COLLECTION_LOCK_WRITE, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_hashlist_iterator_to_key().

void* cp_list_get_tail ( cp_list list  ) 

Returns the last element of the list.

Definition at line 438 of file linked_list.c.

References COLLECTION_LOCK_WRITE, cp_list_txlock(), and cp_list_txunlock().

void* cp_list_insert ( cp_list list,
void *  item 
)

Insert a new element at the beginning of the list. The operation is synchronized according to the properties of the object.

Definition at line 230 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_db_connection_pool_release_connection(), and lookup_internal().

void* cp_list_insert_after ( cp_list list,
void *  item,
void *  existing 
)

Insert the element after an existing one.

Definition at line 283 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

void* cp_list_insert_before ( cp_list list,
void *  item,
void *  existing 
)

Insert the element before an existing one.

Definition at line 327 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

int cp_list_is_empty ( cp_list list  ) 

Test if object is empty.

Return values:
true if no element contained.
false if at least one element is contained.

Definition at line 497 of file linked_list.c.

References COLLECTION_LOCK_READ, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_thread_pool_get_impl().

long cp_list_item_count ( cp_list  ) 

Get the number of elements in the collection.

Returns:
number of elements in the list.
Return values:
0 if list is NULL

Definition at line 214 of file linked_list.c.

Referenced by cp_db_connection_pool_shutdown(), cp_db_register_dbms(), and cp_thread_pool_count_available().

void* cp_list_iterator_append ( cp_list_iterator iterator,
void *  item 
)

append item to the list just after the current iterator position. In the special case that the iterator has been moved beyond the list head the new item is added at the head of the list.

Returns:
the added item or NULL if the list mode is not & COLLECTION_MODE_NOSYNC and the iterator does not own a write lock

Definition at line 879 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_NOSYNC, and cp_list_entry.

void* cp_list_iterator_curr ( cp_list_iterator iterator  ) 

returns the value at the current iterator position

Returns:
value at the current position.
Return values:
NULL if list is empty.

Definition at line 824 of file linked_list.c.

int cp_list_iterator_head ( cp_list_iterator iterator  ) 

Move the iterator to the beginning of the list.

Definition at line 743 of file linked_list.c.

int cp_list_iterator_init ( cp_list_iterator iterator,
cp_list list,
int  lock_mode 
)

Initialize the Iterator at the first position.

Set the iterator at the beginning of the list and lock the list in the mode specified in type.

Parameters:
iterator the iterator object
list the list to iterate over
lock_mode locking mode to use
Return values:
return-code of the aquired lock
0 if no locking

Definition at line 734 of file linked_list.c.

References cp_list_txlock().

int cp_list_iterator_init_tail ( cp_list_iterator iterator,
cp_list list,
int  lock_mode 
)

Initialize the Iterator at the end.

Set the iterator at the end of the list and lock the list in the mode specified in type.

Parameters:
iterator the iterator object
list the list to iterate over
lock_mode locking mode to use
Return values:
return-code of the aquired lock
0 if no locking

Definition at line 759 of file linked_list.c.

References cp_list_txlock().

void* cp_list_iterator_insert ( cp_list_iterator iterator,
void *  item 
)

insert item to the list just before the current iterator position. In the special case that the iterator has been moved beyond the list end the new item is added at the end of the list.

Returns:
the added item or NULL if the list mode is not & COLLECTION_MODE_NOSYNC and the iterator does not own a write lock

Definition at line 834 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_NOSYNC, and cp_list_entry.

void* cp_list_iterator_next ( cp_list_iterator iterator  ) 

Go to the next entry in the list and return the content.

Returns:
object of the next entry.
Return values:
NULL if reading beyond end or from empty list.

Definition at line 786 of file linked_list.c.

Referenced by cp_thread_pool_stop().

void* cp_list_iterator_prev ( cp_list_iterator iterator  ) 

Go to the previous entry in the list and return the content.

Returns:
object of the previous entry.
Return values:
NULL if reading beyond beginning or from empty list.

Definition at line 805 of file linked_list.c.

int cp_list_iterator_release ( cp_list_iterator iterator  ) 

unlock the list the iterator is operating on.

Definition at line 769 of file linked_list.c.

References COLLECTION_LOCK_NONE, and cp_list_txunlock().

Referenced by cp_list_iterator_destroy().

void* cp_list_iterator_remove ( cp_list_iterator iterator  ) 

delete the item at the current iterator position.

Returns:
the deleted item or NULL the list is empty, if the iterator points beyond list limits or if the list mode is not & COLLECTION_MODE_NOSYNC and the iterator does not own a write lock

Definition at line 924 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_DEEP, COLLECTION_MODE_NOSYNC, cp_list_entry, _cp_list_entry::next, and _cp_list_entry::prev.

int cp_list_iterator_tail ( cp_list_iterator iterator  ) 

Move the iterator to the end of the list.

Definition at line 751 of file linked_list.c.

int cp_list_lock ( cp_list list,
int  mode 
)

Locks the collection with the specified mode.

This overrides the default mode stored in the object.

Definition at line 550 of file linked_list.c.

References COLLECTION_MODE_IN_TRANSACTION, COLLECTION_MODE_NOSYNC, and cp_list_lock_internal().

void* cp_list_remove ( cp_list list,
void *  item 
)

Remove the element from the list. The operation is synchronized according to the properties of the object.

Definition at line 251 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_DEEP, COLLECTION_MODE_MULTIPLE_VALUES, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

void* cp_list_remove_head ( cp_list list  ) 

remove and release first entry

Returns:
previous list head

Definition at line 450 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_DEEP, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_db_connection_pool_get_connection(), cp_db_connection_pool_shutdown(), cp_http_thread_fn(), cp_result_set_destroy(), cp_result_set_next(), and cp_thread_pool_get_impl().

void* cp_list_remove_tail ( cp_list list  ) 

remove and release last entry

Returns:
Element that was stored in the last entry.

Definition at line 474 of file linked_list.c.

References COLLECTION_LOCK_WRITE, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_priority_list_get_next_by_option().

void* cp_list_search ( cp_list list,
void *  item 
)

Get the first element that equals the parameter.

Definition at line 370 of file linked_list.c.

References COLLECTION_LOCK_READ, cp_list_entry, cp_list_txlock(), and cp_list_txunlock().

Referenced by cp_priority_list_insert_by_option().

int cp_list_unlock ( cp_list list  ) 

Unlock the object.

Definition at line 562 of file linked_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_IN_TRANSACTION, and cp_list_unlock_internal().


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