Implementation of cp_list Collection with linked elements and cp_list_iterator. More...
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "linked_list.h"
Functions | |
int | cp_list_txlock (cp_list *list, int type) |
int | cp_list_txunlock (cp_list *list) |
static cp_list_entry * | cp_list_create_entry (cp_list *list, void *item) |
Creates an entry with the mode of the list. | |
static cp_list_entry * | cp_list_insert_internal (cp_list *list, void *item) |
Unsynchronized and unchecked insert a new element at the beginning of the list. | |
static cp_list_entry * | cp_list_remove_internal (cp_list *list, cp_list_entry *entry) |
Unsynchronized and unchecked remove the entry from the list. | |
static cp_list_entry * | cp_list_append_internal (cp_list *list, void *item) |
Appends the element and returns the Entry. | |
static cp_list_entry * | cp_list_remove_head_internal (cp_list *list) |
Removes the first entry from the list and returns it. | |
static cp_list_entry * | cp_list_remove_tail_internal (cp_list *list) |
Removes the last entry from the list and returns it. | |
cp_list * | cp_list_create_internal (int mode, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor, int is_view) |
cp_list * | cp_list_create () |
Default constructor. | |
cp_list * | cp_list_create_nosync () |
cp_list * | cp_list_create_list (int mode, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor) |
Constructor. | |
cp_list * | cp_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) |
Destroy the object with the mode stored in the list. | |
void | cp_list_destroy_by_option (cp_list *list, int option) |
Destroy the object with the specified mode (override default). | |
void | cp_list_destroy_custom (cp_list *list, cp_destructor_fn fn) |
Destroy the object and all contained elements. | |
long | cp_list_item_count (cp_list *list) |
Get the number of elements in the collection. | |
static cp_list_entry ** | cp_list_get_entry_ref (cp_list *list, void *item) |
void * | cp_list_insert (cp_list *list, void *item) |
Insert a new element at the beginning of the list. | |
void * | cp_list_remove (cp_list *list, void *item) |
Remove the element from the list. | |
void * | cp_list_insert_after (cp_list *list, void *item, void *existing) |
Insert the element after an existing one. | |
void * | cp_list_insert_before (cp_list *list, void *item, void *existing) |
Insert the element before an existing one. | |
void * | cp_list_search (cp_list *list, void *item) |
Get the first element that equals the parameter. | |
int | cp_list_callback (cp_list *l, int(*item_action)(void *, void *), void *id) |
run a callback on each item. | |
void * | cp_list_append (cp_list *list, void *item) |
Append the element at the end of the list. | |
void * | cp_list_get_head (cp_list *list) |
Returns the first element of the list. | |
void * | cp_list_get_tail (cp_list *list) |
Returns the last element of the list. | |
void * | cp_list_remove_head (cp_list *list) |
remove and release first entry | |
void * | cp_list_remove_tail (cp_list *list) |
remove and release last entry | |
int | cp_list_is_empty (cp_list *list) |
Test if object is empty. | |
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) |
Locks the collection with the specified mode. | |
int | cp_list_unlock (cp_list *list) |
Unlock the object. | |
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_iterator * | cp_list_create_iterator (cp_list *list, int type) |
create a new iterator and initialize it at the beginning of the list. | |
int | cp_list_iterator_init (cp_list_iterator *iterator, cp_list *list, int type) |
Initialize the Iterator at the first position. | |
int | cp_list_iterator_head (cp_list_iterator *iterator) |
Move the iterator to the beginning of the list. | |
int | cp_list_iterator_tail (cp_list_iterator *iterator) |
Move the iterator to the end of the list. | |
int | cp_list_iterator_init_tail (cp_list_iterator *iterator, cp_list *list, int type) |
Initialize the Iterator at the end. | |
int | cp_list_iterator_release (cp_list_iterator *iterator) |
unlock the list the iterator is operating on. | |
int | cp_list_iterator_destroy (cp_list_iterator *iterator) |
void * | cp_list_iterator_next (cp_list_iterator *iterator) |
Go to the next entry in the list and return the content. | |
void * | cp_list_iterator_prev (cp_list_iterator *iterator) |
Go to the previous entry in the list and return the content. | |
void * | cp_list_iterator_curr (cp_list_iterator *iterator) |
returns the value at the current iterator position | |
void * | cp_list_iterator_insert (cp_list_iterator *iterator, void *item) |
insert item to the list just before the current iterator position. | |
void * | cp_list_iterator_append (cp_list_iterator *iterator, void *item) |
append item to the list just after the current iterator position. | |
void * | cp_list_iterator_remove (cp_list_iterator *iterator) |
delete the item at the current iterator position. |
Implementation of cp_list Collection with linked elements and cp_list_iterator.
The elements are stored in cp_list_entry objects.