void* cp_hashlist_append | ( | cp_hashlist * | list, | |
void * | key, | |||
void * | value | |||
) |
Append a new element (key, value) at the end of the list. The operation is synchronized according to the properties of the object.
key != NULL
Definition at line 403 of file hashlist.c.
References cp_hashlist_append_by_option().
Referenced by cp_http_thread_fn(), cp_httpclient_fetch_ctl(), cp_httpsocket_create(), cp_multimap_create_by_option(), cp_socket_create(), cp_socket_select_callback_impl(), cp_socket_select_threadpool_impl(), and cp_thread_pool_get_impl().
void* cp_hashlist_append_by_option | ( | cp_hashlist * | , | |
void * | key, | |||
void * | value, | |||
int | mode | |||
) |
Append a new element (key, value) at the end of the list with mode.
Definition at line 440 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_append().
int cp_hashlist_callback | ( | cp_hashlist * | list, | |
int(*)(void *key, void *value, void *id) | cb, | |||
void * | id | |||
) |
iterates over the list and calls the callback function on each item.
list | the hashlist | |
dk | if not NULL, this function is invoked with the key for each entry | |
dv | if not NULL, this function is invoked with the value for each entry |
Definition at line 265 of file hashlist.c.
References COLLECTION_LOCK_READ, cp_hashlist_txlock(), and cp_hashlist_txunlock().
int cp_hashlist_contains | ( | cp_hashlist * | list, | |
void * | key | |||
) |
returns non-zero if list contains key
Definition at line 429 of file hashlist.c.
References COLLECTION_LOCK_READ, cp_hashlist_txlock(), and cp_hashlist_txunlock().
cp_hashlist* cp_hashlist_create_by_mode | ( | int | mode, | |
unsigned long | size_hint, | |||
cp_hashfunction | hash_fn, | |||
cp_compare_fn | compare_fn | |||
) |
constructor with parameters.
operation | mode bitmap (see collection.h) | |
size_hint | initial size of the cp_hashtable | |
hash_fn | hash method | |
compare_fn | hash compare method |
Definition at line 153 of file hashlist.c.
References cp_hashlist_create_by_option().
Referenced by cp_http_init(), and cp_socket_init().
cp_hashlist* cp_hashlist_create_by_option | ( | int | mode, | |
unsigned long | size_hint, | |||
cp_hashfunction | hash_fn, | |||
cp_compare_fn | compare_fn, | |||
cp_copy_fn | copy_key, | |||
cp_destructor_fn | free_key, | |||
cp_copy_fn | copy_value, | |||
cp_destructor_fn | free_value | |||
) |
Constructor for copy mode.
mode | Bitmap of operation mode (see collection.h) | |
size_hint | initial size of the cp_hashtable | |
hash_fn | hash method | |
compare_fn | hash compare method | |
copy_key | copy key method | |
copy_value | copy value method |
Definition at line 90 of file hashlist.c.
References COLLECTION_MODE_NOSYNC, cp_hashtable_choose_size(), CP_HASHTABLE_DEFAULT_MAX_FILL_FACTOR, CP_HASHTABLE_DEFAULT_MIN_FILL_FACTOR, and _cp_hashlist::table_size.
Referenced by cp_hashlist_create_by_mode(), cp_multimap_create_by_option(), cp_multimap_create_index(), and cp_socket_create().
cp_hashlist_iterator* cp_hashlist_create_iterator | ( | cp_hashlist * | list, | |
int | lock_mode | |||
) |
Create a new iterator and initialize it at the beginning.
list | list to iterate over | |
lock_mode | locking mode to use |
Definition at line 857 of file hashlist.c.
References COLLECTION_LOCK_READ, COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), CP_LOCK_FAILED, and CP_MEMORY_ALLOCATION_FAILURE.
Referenced by cp_multimap_create_index(), cp_multimap_insert(), cp_socket_delete(), cp_socket_select_callback_impl(), and cp_thread_pool_stop().
void cp_hashlist_destroy | ( | cp_hashlist * | ) |
Destroy the list with the mode stored in the list.
Definition at line 237 of file hashlist.c.
Referenced by cp_multimap_create_by_option(), cp_multimap_destroy(), cp_socket_shutdown(), and cp_thread_pool_destroy().
void cp_hashlist_destroy_by_option | ( | cp_hashlist * | list, | |
int | mode | |||
) |
Destroy the object with the specified mode (override default).
list | the object | |
mode | locking mode |
Definition at line 249 of file hashlist.c.
void cp_hashlist_destroy_custom | ( | cp_hashlist * | list, | |
cp_destructor_fn | dk, | |||
cp_destructor_fn | dv | |||
) |
This function does exactly what you would think it does. Before it didn't - that was a bug. Now it does.
Definition at line 257 of file hashlist.c.
Referenced by cp_hashlist_destroy_deep(), cp_http_shutdown(), cp_httpclient_ctl_destroy(), cp_httpsocket_delete(), cp_socket_delete(), and cp_thread_pool_create().
void cp_hashlist_destroy_deep | ( | cp_hashlist * | ) |
Destroy the list with the mode stored in the list plus COLLECTION_MODE_DEEP.
Definition at line 243 of file hashlist.c.
References cp_hashlist_destroy_custom(), and cp_hashlist_set_mode().
Referenced by cp_httpsocket_delete().
void* cp_hashlist_entry_get_key | ( | cp_hashlist_entry * | entry | ) |
Get the key of the entry.
key | of the entry. | |
NULL | if entry is NULL |
Definition at line 835 of file hashlist.c.
Referenced by cp_hashlist_iterator_curr_key(), cp_hashlist_iterator_next_key(), cp_hashlist_iterator_prev_key(), cp_socket_delete(), and cp_socket_select_callback_impl().
void* cp_hashlist_entry_get_value | ( | cp_hashlist_entry * | entry | ) |
Get the value of the entry.
value | of the entry. | |
NULL | if entry is NULL |
Definition at line 840 of file hashlist.c.
Referenced by cp_hashlist_iterator_curr_value(), cp_hashlist_iterator_next_value(), and cp_hashlist_iterator_prev_value().
void* cp_hashlist_get | ( | cp_hashlist * | , | |
void * | key | |||
) |
Returns the first element with matching key.
Definition at line 531 of file hashlist.c.
References COLLECTION_LOCK_READ, COLLECTION_MODE_MULTIPLE_VALUES, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_http_thread_fn(), cp_multimap_callback_by_index(), cp_multimap_find_by_index(), cp_multimap_get_by_index(), cp_multimap_remove_by_index(), cp_socket_connection_close(), and cp_socket_select_threadpool_impl().
void* cp_hashlist_get_head | ( | cp_hashlist * | ) |
Returns the first element of the list.
Definition at line 601 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
int cp_hashlist_get_mode | ( | cp_hashlist * | list | ) |
find out what mode your cp_hashlist is running in
Definition at line 291 of file hashlist.c.
void* cp_hashlist_get_tail | ( | cp_hashlist * | ) |
Returns the last element of the list.
Definition at line 613 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
void* cp_hashlist_insert | ( | cp_hashlist * | list, | |
void * | key, | |||
void * | value | |||
) |
Insert a new element (key, value) at the beginning of the list. The operation is synchronized according to the properties of the object.
key != NULL
Definition at line 484 of file hashlist.c.
References cp_hashlist_insert_by_option().
Referenced by cp_multimap_create_index().
void* cp_hashlist_insert_by_option | ( | cp_hashlist * | list, | |
void * | key, | |||
void * | item, | |||
int | mode | |||
) |
Insert a new element (key, value) at the beginning of the list with mode.
Definition at line 490 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_insert().
int cp_hashlist_is_empty | ( | cp_hashlist * | list | ) |
Test if object is empty.
true | if no element contained. | |
false | if at least one element is contained. |
Definition at line 845 of file hashlist.c.
References cp_hashlist_item_count().
unsigned long cp_hashlist_item_count | ( | cp_hashlist * | ) |
Get the number of elements in the collection.
0 | if list is NULL |
Definition at line 691 of file hashlist.c.
References COLLECTION_LOCK_READ, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_is_empty(), cp_httpclient_fetch_ctl_exec(), and cp_thread_pool_wait().
cp_hashlist_entry* cp_hashlist_iterator_append | ( | cp_hashlist_iterator * | iterator, | |
void * | key, | |||
void * | value | |||
) |
add a mapping after the current iterator position
Definition at line 1146 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, and COLLECTION_MODE_NOSYNC.
cp_hashlist_entry* cp_hashlist_iterator_curr | ( | cp_hashlist_iterator * | iterator | ) |
return the entry at the current iterator position
Definition at line 1066 of file hashlist.c.
Referenced by cp_hashlist_iterator_curr_key(), and cp_hashlist_iterator_curr_value().
void* cp_hashlist_iterator_curr_key | ( | cp_hashlist_iterator * | iterator | ) |
return the key at the current iterator position
Definition at line 1076 of file hashlist.c.
References cp_hashlist_entry_get_key(), and cp_hashlist_iterator_curr().
void* cp_hashlist_iterator_curr_value | ( | cp_hashlist_iterator * | iterator | ) |
return the value at the current iterator position
Definition at line 1081 of file hashlist.c.
References cp_hashlist_entry_get_value(), and cp_hashlist_iterator_curr().
int cp_hashlist_iterator_destroy | ( | cp_hashlist_iterator * | iterator | ) |
iterator destructor
Definition at line 1000 of file hashlist.c.
References cp_hashlist_iterator_release().
Referenced by cp_multimap_create_index(), cp_multimap_insert(), cp_socket_delete(), cp_socket_select_callback_impl(), and cp_thread_pool_stop().
int cp_hashlist_iterator_head | ( | cp_hashlist_iterator * | iterator | ) |
initialize the iterator at the beginning
set the iterator at the beginning of the list and lock the list in the mode specified in type.
Definition at line 922 of file hashlist.c.
Referenced by cp_socket_select_callback_impl().
int cp_hashlist_iterator_init_tail | ( | cp_hashlist_iterator * | iterator, | |
cp_hashlist * | l, | |||
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.
Definition at line 938 of file hashlist.c.
References COLLECTION_LOCK_READ, COLLECTION_LOCK_WRITE, and cp_hashlist_txlock().
cp_hashlist_entry* cp_hashlist_iterator_insert | ( | cp_hashlist_iterator * | iterator, | |
void * | key, | |||
void * | value | |||
) |
add a mapping before the current iterator position
Definition at line 1086 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, and COLLECTION_MODE_NOSYNC.
cp_hashlist_entry* cp_hashlist_iterator_next | ( | cp_hashlist_iterator * | iterator | ) |
Go to the next entry in the list and return the content.
entry | the next entry object. | |
NULL | if reading beyond end or from empty list. |
Definition at line 1008 of file hashlist.c.
Referenced by cp_hashlist_iterator_next_key(), cp_hashlist_iterator_next_value(), cp_multimap_create_index(), cp_multimap_insert(), cp_socket_delete(), and cp_socket_select_callback_impl().
void* cp_hashlist_iterator_next_key | ( | cp_hashlist_iterator * | iterator | ) |
Go to the next entry in the list and return the key.
NULL | if reading beyond end or from empty list. |
Definition at line 1027 of file hashlist.c.
References cp_hashlist_entry_get_key(), and cp_hashlist_iterator_next().
void* cp_hashlist_iterator_next_value | ( | cp_hashlist_iterator * | iterator | ) |
Go to the next entry in the list and return the content.
NULL | if reading beyond end or from empty list. |
Definition at line 1032 of file hashlist.c.
References cp_hashlist_entry_get_value(), and cp_hashlist_iterator_next().
Referenced by cp_multimap_contains(), cp_multimap_reindex(), cp_socket_stop_all(), and cp_thread_pool_stop().
cp_hashlist_entry* cp_hashlist_iterator_prev | ( | cp_hashlist_iterator * | iterator | ) |
Go to the previous entry in the list and return the content.
entry | the previous entry object. | |
NULL | if reading beyond beginning or from empty list. |
Definition at line 1037 of file hashlist.c.
Referenced by cp_hashlist_iterator_prev_key(), cp_hashlist_iterator_prev_value(), and cp_multimap_insert().
void* cp_hashlist_iterator_prev_key | ( | cp_hashlist_iterator * | iterator | ) |
Go to the previous entry in the list and return the key.
NULL | if reading beyond beginning or from empty list. |
Definition at line 1056 of file hashlist.c.
References cp_hashlist_entry_get_key(), and cp_hashlist_iterator_prev().
void* cp_hashlist_iterator_prev_value | ( | cp_hashlist_iterator * | iterator | ) |
Go to the previous entry in the list and return the content.
NULL | if reading beyond beginning or from empty list. |
Definition at line 1061 of file hashlist.c.
References cp_hashlist_entry_get_value(), and cp_hashlist_iterator_prev().
int cp_hashlist_iterator_release | ( | cp_hashlist_iterator * | iterator | ) |
Unlock the list of the Iterator.
If the locking mode is COLLECTION_LOCK_NONE, do nothing.
Definition at line 991 of file hashlist.c.
References COLLECTION_LOCK_NONE, and cp_hashlist_txunlock().
Referenced by cp_hashlist_iterator_destroy(), cp_multimap_contains(), cp_multimap_reindex(), and cp_socket_stop_all().
void* cp_hashlist_iterator_remove | ( | cp_hashlist_iterator * | iterator | ) |
remove the mapping at the current iterator position
Definition at line 1206 of file hashlist.c.
References COLLECTION_LOCK_WRITE, and COLLECTION_MODE_NOSYNC.
int cp_hashlist_iterator_tail | ( | cp_hashlist_iterator * | iterator | ) |
set iterator at list tail
Definition at line 930 of file hashlist.c.
int cp_hashlist_iterator_to_key | ( | cp_hashlist_iterator * | iterator, | |
void * | key | |||
) |
set iterator position at first occurence of given key
Definition at line 962 of file hashlist.c.
References COLLECTION_MODE_MULTIPLE_VALUES, cp_list_destroy(), and cp_list_get_head().
int cp_hashlist_lock | ( | cp_hashlist * | list, | |
int | type | |||
) |
Locks the collection with the specified mode.
This overrides the default mode stored in the object.
Definition at line 781 of file hashlist.c.
References COLLECTION_MODE_IN_TRANSACTION, COLLECTION_MODE_NOSYNC, cp_hashlist_lock_internal(), and DEBUGMSG.
void* cp_hashlist_remove | ( | cp_hashlist * | list, | |
void * | key | |||
) |
Removes the entry with matching key and destroys it (internal locking mode).
list | the object | |
key | Key which is searched. |
value | that was stored in the entry. | |
NULL | if key was not found |
Definition at line 589 of file hashlist.c.
References cp_hashlist_remove_by_option().
Referenced by cp_http_thread_fn(), cp_httpsocket_delete(), and cp_socket_delete().
CPROPS_DLL void * cp_hashlist_remove_by_option | ( | cp_hashlist * | list, | |
void * | key, | |||
int | mode | |||
) |
Removes the entry with matching key and destroys it with locking mode.
list | the object | |
key | Key which is searched. | |
mode | locking mode |
value | that was stored in the entry. | |
NULL | if key was not found |
Definition at line 574 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_remove(), cp_hashlist_remove_deep(), and cp_multimap_destroy().
void* cp_hashlist_remove_head | ( | cp_hashlist * | list | ) |
Removes the first entry and destroys it.
Definition at line 626 of file hashlist.c.
References cp_hashlist_remove_head_by_option().
void* cp_hashlist_remove_head_by_option | ( | cp_hashlist * | list, | |
int | mode | |||
) |
Removes the first entry and destroys it.
list | the object | |
mode | locking mode |
Definition at line 631 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_remove_head().
void* cp_hashlist_remove_tail | ( | cp_hashlist * | list | ) |
Removes the last entry and destroys it.
Element | that was stored in the first entry if not empty. | |
NULL | if collection is empty |
Definition at line 659 of file hashlist.c.
References cp_hashlist_remove_tail_by_option().
void* cp_hashlist_remove_tail_by_option | ( | cp_hashlist * | list, | |
int | mode | |||
) |
Removes the last entry and destroys it.
list | the object | |
mode | locking mode |
Definition at line 664 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_remove_tail().
int cp_hashlist_set_max_fill_factor | ( | cp_hashlist * | list, | |
int | fill_factor | |||
) |
a resize is triggered when the table contains more items than table_size * fill_factor / 100
Definition at line 339 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
int cp_hashlist_set_min_fill_factor | ( | cp_hashlist * | list, | |
int | fill_factor | |||
) |
a resize is triggered when the table contains less items than table_size * fill_factor / 100 if table_size > min_size
Definition at line 347 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
int cp_hashlist_set_min_size | ( | cp_hashlist * | list, | |
unsigned long | min_size | |||
) |
the internal table will not be resized to less than min_size
Definition at line 330 of file hashlist.c.
References COLLECTION_LOCK_WRITE, cp_hashlist_txlock(), and cp_hashlist_txunlock().
int cp_hashlist_set_mode | ( | cp_hashlist * | list, | |
int | mode | |||
) |
set the mode on your cp_hashlist
Definition at line 296 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_IN_TRANSACTION, COLLECTION_MODE_NOSYNC, cp_hashlist_txlock(), and cp_hashlist_txunlock().
Referenced by cp_hashlist_destroy_deep().
int cp_hashlist_unlock | ( | cp_hashlist * | list | ) |
Unlock the object.
Definition at line 805 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_IN_TRANSACTION, COLLECTION_MODE_NOSYNC, cp_hashlist_unlock_internal(), and DEBUGMSG.
int cp_hashlist_unset_mode | ( | cp_hashlist * | list, | |
int | mode | |||
) |
unset mode bits on list
Definition at line 319 of file hashlist.c.
References COLLECTION_LOCK_WRITE, COLLECTION_MODE_NOSYNC, cp_hashlist_txlock(), and cp_hashlist_txunlock().