cucon/list.h: Doubly Linked Lists
[Linear Containers (lists, stacks, arrays)]

Data Structures

struct  cucon_listnode
struct  cucon_list

Defines

#define cucon_list_empty()   (&cuconP_list_empty)
#define cucon_list_clear   cucon_list_init

Functions

void cucon_list_init (cucon_list_t)
cucon_list_t cucon_list_new (void)
void cucon_list_init_copy_mem (cucon_list_t dst, cucon_list_t src, size_t size)
cucon_list_t cucon_list_new_copy_mem (cucon_list_t src, size_t size)
void cucon_list_init_copy_ptr (cucon_list_t dst, cucon_list_t src)
cucon_list_t cucon_list_new_copy_ptr (cucon_list_t src)
void cucon_list_swap (cucon_list_t lst0, cucon_list_t lst1)
cu_bool_t cucon_list_is_empty (cucon_list_t list)
cu_bool_t cucon_list_is_empty_or_singleton (cucon_list_t list)
cu_bool_t cucon_list_is_singleton (cucon_list_t list)
void cucon_list_validate (cucon_list_t list)
int cucon_list_cmp_mem (cucon_list_t lhs, cucon_list_t rhs, size_t slot_size)
int cucon_list_cmp_ptr (cucon_list_t lhs, cucon_list_t rhs)
size_t cucon_list_count (cucon_list_t list)
cucon_listnode_t cucon_list_find_ptr (cucon_list_t list, void *ptr)
cucon_listnode_t cucon_list_begin (cucon_list_t list)
cucon_listnode_t cucon_list_end (cucon_list_t list)
cucon_listnode_t cucon_list_rbegin (cucon_list_t list)
cucon_listnode_t cucon_list_rend (cucon_list_t list)
void cucon_list_insert_init (cucon_listnode_t pos, cucon_listnode_t new_node)
void cucon_list_insert_live (cucon_listnode_t pos, cucon_listnode_t node)
cucon_listnode_t cucon_list_insert_mem (cucon_listnode_t node, size_t size)
cucon_listnode_t cucon_list_insert_ptr (cucon_listnode_t node, void *ptr)
cucon_listnode_t cucon_list_extract (cucon_listnode_t node)
void * cucon_list_extract_mem (cucon_listnode_t node)
void * cucon_list_extract_ptr (cucon_listnode_t node)
cucon_listnode_t cucon_list_erase_node (cucon_listnode_t node)
cucon_listnode_t cucon_list_erase_ptr (cucon_list_t list, void *ptr)
size_t cucon_list_erase_all_ptr (cucon_list_t list, void *ptr)
void cucon_list_rotate (cucon_list_t list, cucon_listnode_t first_node)
void cucon_list_rotate_backwards (cucon_list_t list)
void * cucon_listnode_mem (cucon_listnode_t node)
void * cucon_listnode_ptr (cucon_listnode_t node)
void cucon_listnode_set_ptr (cucon_listnode_t node, void *ptr)
cucon_listnode_t cucon_listnode_next (cucon_listnode_t node)
cucon_listnode_t cucon_listnode_prev (cucon_listnode_t node)
void cucon_list_range_iter_mem (cucon_listnode_t, cucon_listnode_t, cu_clop(proc, void, void *))
cu_ptr_source_t cucon_listrange_source_ptr (cucon_listnode_t begin, cucon_listnode_t end)
cu_ptr_source_t cucon_list_source_ptr (cucon_list_t list)
void cucon_list_prepend_init (cucon_list_t list, cucon_listnode_t node)
void cucon_list_prepend_live (cucon_list_t list, cucon_listnode_t node)
cucon_listnode_t cucon_list_prepend_mem (cucon_list_t list, size_t size)
cucon_listnode_t cucon_list_prepend_ptr (cucon_list_t list, void *p)
void cucon_list_append_init (cucon_list_t list, cucon_listnode_t node)
void cucon_list_append_live (cucon_list_t list, cucon_listnode_t node)
cucon_listnode_t cucon_list_append_mem (cucon_list_t list, size_t size)
cucon_listnode_t cucon_list_append_ptr (cucon_list_t list, void *p)
cucon_listnode_t cucon_list_append_list_dct (cucon_list_t dst, cucon_list_t src)
cucon_listnode_t cucon_list_prepend_list_dct (cucon_list_t dst, cucon_list_t src)
void * cucon_list_front_mem (cucon_list_t list)
void * cucon_list_back_mem (cucon_list_t list)
void * cucon_list_front_ptr (cucon_list_t list)
void * cucon_list_back_ptr (cucon_list_t list)
void cucon_list_pop_front (cucon_list_t list)
void cucon_list_pop_back (cucon_list_t list)

Variables

struct cucon_list cuconP_list_empty

Define Documentation

#define cucon_list_clear   cucon_list_init

Clear the list.

 
#define cucon_list_empty (  )     (&cuconP_list_empty)

Return an empty list constant. Don't change it!


Function Documentation

void cucon_list_append_init ( cucon_list_t  list,
cucon_listnode_t  node 
)

Insert and construct node at end of list.

cucon_listnode_t cucon_list_append_list_dct ( cucon_list_t  dst,
cucon_list_t  src 
)

Append src to dst, descructing src.

void cucon_list_append_live ( cucon_list_t  list,
cucon_listnode_t  node 
)

Move a live node to the back of list.

cucon_listnode_t cucon_list_append_mem ( cucon_list_t  list,
size_t  size 
)

Insert an element as the last in the list.

cucon_listnode_t cucon_list_append_ptr ( cucon_list_t  list,
void *  p 
)

Insert a pointer as the last in the list.

void* cucon_list_back_mem ( cucon_list_t  list  ) 

A pointer to the slot of the last element of list.

Precondition:
list is non-empty.
void* cucon_list_back_ptr ( cucon_list_t  list  ) 

The value of the last element of list, assuming it is a pointer.

Precondition:
list is non-empty.
cucon_listnode_t cucon_list_begin ( cucon_list_t  list  ) 

Return an iterator to the first element of list.

int cucon_list_cmp_mem ( cucon_list_t  lhs,
cucon_list_t  rhs,
size_t  slot_size 
)

Return an integer less than, equal to, or greater than zero if lhs is less than, equal to, or greater than rhs, respectively, considering an element by element memcmp of the slots of size bytes. If the lists are otherwise equal, the shorter one is considered to be the lesser.

int cucon_list_cmp_ptr ( cucon_list_t  lhs,
cucon_list_t  rhs 
)

Currently implemented as cucon_list_cmp_mem, but may use pointer comparison in future versions.

size_t cucon_list_count ( cucon_list_t  list  ) 

Return the number of elements in list. This takes linear time, use cucon_list_is_empty or cucon_list_is_singleton whenever possible.

cucon_listnode_t cucon_list_end ( cucon_list_t  list  ) 

Return an iterater past the last element of list.

size_t cucon_list_erase_all_ptr ( cucon_list_t  list,
void *  ptr 
)

Erase all elements of list which equals ptr and return the number of elements erased.

cucon_listnode_t cucon_list_erase_node ( cucon_listnode_t  node  ) 

Erase element pointed to by node from its list and return an iterator to the next element.

cucon_listnode_t cucon_list_erase_ptr ( cucon_list_t  list,
void *  ptr 
)

Erase the first element from list which equals ptr and return an iterator to the element after it, or end-of-list if nothing was erased. All elements of list must start with a pointer. If you need to know if an element was actually erased, use cucon_list_find_ptr and cucon_list_erase_node.

cucon_listnode_t cucon_list_extract ( cucon_listnode_t  node  ) 

Remove node from its list and return it as an isolated node.

void* cucon_list_extract_mem ( cucon_listnode_t  node  ) 

Return a pointer to the value slot of node after unlinking it from its list.

void* cucon_list_extract_ptr ( cucon_listnode_t  node  ) 

Return the pointer stored as the value of node after unlinking it from its list.

cucon_listnode_t cucon_list_find_ptr ( cucon_list_t  list,
void *  ptr 
)

Return the node containing a pointer ptr, or NULL if ptr is not in list.

Precondition:
All element slots of list must start with a pointer.
void* cucon_list_front_mem ( cucon_list_t  list  ) 

A pointer to the slot of the first element of list.

Precondition:
list is non-empty.
void* cucon_list_front_ptr ( cucon_list_t  list  ) 

The value of the first element of list, assuming it is a pointer.

Precondition:
list is non-empty.
void cucon_list_init ( cucon_list_t   ) 

Create an empty list.

void cucon_list_init_copy_mem ( cucon_list_t  dst,
cucon_list_t  src,
size_t  size 
)

Create a copy of src using memcpy assuming slots are size bytes.

void cucon_list_init_copy_ptr ( cucon_list_t  dst,
cucon_list_t  src 
)

Create a copy of src assuming elements are pointers.

void cucon_list_insert_init ( cucon_listnode_t  pos,
cucon_listnode_t  new_node 
)

Construct new_node, inserting it before pos.

void cucon_list_insert_live ( cucon_listnode_t  pos,
cucon_listnode_t  node 
)

Extract the live node from its list and insert it before pos.

cucon_listnode_t cucon_list_insert_mem ( cucon_listnode_t  node,
size_t  size 
)

Insert a new node with size bytes value before node.

cucon_listnode_t cucon_list_insert_ptr ( cucon_listnode_t  node,
void *  ptr 
)

Insert a new node before node, which holds the pointer ptr.

cu_bool_t cucon_list_is_empty ( cucon_list_t  list  ) 

True iff list is empty.

cu_bool_t cucon_list_is_empty_or_singleton ( cucon_list_t  list  ) 

True iff list is empty or a singleton.

cu_bool_t cucon_list_is_singleton ( cucon_list_t  list  ) 

True iff list has exactly one element.

cucon_list_t cucon_list_new ( void   ) 

Return an empty list.

cucon_list_t cucon_list_new_copy_mem ( cucon_list_t  src,
size_t  size 
)

Create a copy of src using memcpy assuming slots are size bytes.

cucon_list_t cucon_list_new_copy_ptr ( cucon_list_t  src  ) 

Create a copy of src assuming elements are pointers.

void cucon_list_pop_back ( cucon_list_t  list  ) 

Erase the last element of list.

Precondition:
list is non-empty.
void cucon_list_pop_front ( cucon_list_t  list  ) 

Erase the first element of list.

Precondition:
list is non-empty.
void cucon_list_prepend_init ( cucon_list_t  list,
cucon_listnode_t  node 
)

Insert and construct node as first element of list.

cucon_listnode_t cucon_list_prepend_list_dct ( cucon_list_t  dst,
cucon_list_t  src 
)

Prepend src to dst, descructing src.

void cucon_list_prepend_live ( cucon_list_t  list,
cucon_listnode_t  node 
)

Move node from its list to the front of list.

cucon_listnode_t cucon_list_prepend_mem ( cucon_list_t  list,
size_t  size 
)

Insert an element as the first in the list.

cucon_listnode_t cucon_list_prepend_ptr ( cucon_list_t  list,
void *  p 
)

Insert a pointer as the first in the list.

void cucon_list_range_iter_mem ( cucon_listnode_t  ,
cucon_listnode_t  ,
cu_clop(proc, void, void *)   
)

Call proc with all values in the iterator range.

cucon_listnode_t cucon_list_rbegin ( cucon_list_t  list  ) 

An iterator to the first element of the reversed range of list.

cucon_listnode_t cucon_list_rend ( cucon_list_t  list  ) 

An iterator to post the end of the reversed range of list.

void cucon_list_rotate ( cucon_list_t  list,
cucon_listnode_t  first_node 
)

Rotate elements of list so that first_node becomes the first node.

Precondition:
first_node must be an element of list other than EOL.
void cucon_list_rotate_backwards ( cucon_list_t  list  ) 

Move the first element of the list to the end.

cu_ptr_source_t cucon_list_source_ptr ( cucon_list_t  list  ) 

A source over all elements of list dereferenced as pointers.

void cucon_list_swap ( cucon_list_t  lst0,
cucon_list_t  lst1 
)

Swap the elements of lst0 and lst1.

void cucon_list_validate ( cucon_list_t  list  ) 

Validate the integrity of the links of list.

void* cucon_listnode_mem ( cucon_listnode_t  node  ) 

Return a pointer to the value of node.

cucon_listnode_t cucon_listnode_next ( cucon_listnode_t  node  ) 

Return an iterator to the element after that referred by node.

cucon_listnode_t cucon_listnode_prev ( cucon_listnode_t  node  ) 

Return an iterator to the element before that referred by node.

void* cucon_listnode_ptr ( cucon_listnode_t  node  ) 

Return the pointer stored as the value of node.

void cucon_listnode_set_ptr ( cucon_listnode_t  node,
void *  ptr 
)

Set the value of node to the pointer ptr.

Precondition:
The value slot of node must be large enough to hold the pointer.
cu_ptr_source_t cucon_listrange_source_ptr ( cucon_listnode_t  begin,
cucon_listnode_t  end 
)

A source over values from begin up to but not including end where value slot pointers are dereferenced as pointers.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.