struct List / List_t
Concrete Class
Description
The List Class
Implements doubly or singly linked lists.
Throughout the documentation, the following prefixes will be used:
Global_
The library prefix: for applications, this is typically
empty, for an xyz-Library, this is either XYZ_ , xyz_ or
Xyz , depending on the identifier in occurs in.
Template Instantiation
Global_LIST_OK XYZ_LIST_OK
Global_list_new xyz_list_new
List_
This is equivalent to Global_list_oType, or the name
that was set with -name=... for this data structure.
The case and underbar convention is adjusted, too.
Assuming a library prefix xyz and oType == int, you get:
Template Instantiation
List_t xyz_list_int_t
List_ALLOW_NULL XYZ_LIST_INT_ALLOW_NULL
List_class
This is the name of the data structure type in C++: capitalised
and with underbars removed:
Members
void clear_errno ()
int get_errno ()
List_t const & static_zero ()
void operator delete (void * , size_t )
void operator delete[] (void * , size_t )
void * operator new (size_t )
void * operator new[] (size_t )
List ()
List (oTypeTouched )
~List ()
operator List_t * ()
operator List_t const * () const
List_t & operator<< (oTypeTouched o )
List_t & operator= (List_t const & )
List_t & operator= (List_t const * )
void _constructor ()
void _destructor ()
Global_list_key_t append (oTypeTouched o )
List_t & append (List_t const * x )
List_t & append (List_t const & x )
List_t & append_list (List_t const * x )
List_t & append_list (List_t const & x )
Global_list_key_t back () const
List_t & clear ()
void clear_errno () const
bool empty () const
void erase (Global_list_key_t k )
void erase (Global_list_key_t & iter , Global_list_key_t k , bool reverse = false )
void erase_in_loop (Global_list_key_t & iter , Global_list_key_t k , bool reverse = false )
oTypeResult first () const
Global_list_key_t front () const
int get_errno () const
Global_list_key_t init_iterator () const
Global_list_key_t init_iterator_reverse () const
Global_list_key_t insert (Global_list_key_t k , oTypeTouched o , bool backwards )
List_t & insert (Global_list_key_t k , List_t const * x , bool backwards )
List_t & insert (Global_list_key_t k , List_t const & x , bool backwards )
Global_list_key_t insert_after (Global_list_key_t k , oTypeTouched o )
List_t & insert_after (Global_list_key_t k , List_t const * x )
List_t & insert_after (Global_list_key_t k , List_t const & x )
Global_list_key_t insert_before (Global_list_key_t k , oTypeTouched o )
List_t & insert_before (Global_list_key_t k , List_t const * x )
List_t & insert_before (Global_list_key_t k , List_t const & x )
List_t & insert_list (Global_list_key_t k , List_t const * x , bool backwards )
List_t & insert_list (Global_list_key_t k , List_t const & x , bool backwards )
List_t & insert_list_after (Global_list_key_t k , List_t const * x )
List_t & insert_list_after (Global_list_key_t k , List_t const & x )
List_t & insert_list_before (Global_list_key_t k , List_t const * x )
List_t & insert_list_before (Global_list_key_t k , List_t const & x )
oTypeResult last () const
int nentries () const
Global_list_key_t next (Global_list_key_t k ) const
bool next_iteration (Global_list_key_t * a , oType * b ) const
bool next_iteration_ptr (Global_list_key_t * a , oTypeVar * * b )
bool next_iteration_ptr_reverse (Global_list_key_t * a , oTypeVar * * b )
bool next_iteration_reverse (Global_list_key_t * a , oType * b ) const
bool non_empty () const
oTypeResult nth (int k ) const
Global_list_key_t nth_key (int k ) const
void overwrite (Global_list_key_t k , oTypeTouched o )
Global_list_key_t prepend (oTypeTouched o )
List_t & prepend (List_t const * x )
List_t & prepend (List_t const & x )
List_t & prepend_list (List_t const * x )
List_t & prepend_list (List_t const & x )
Global_list_key_t prev (Global_list_key_t k ) const
Global_list_key_t previous (Global_list_key_t k ) const
oTypeResult value (Global_list_key_t k ) const
List_element_ptr_t value_ptr (Global_list_key_t k )
List_element_ref_t value_ref (Global_list_key_t k )
Detailed Descriptions
#if !Global_ERWIN_DEFAULT_NEW_DELETE
static void * operator new (size_t )
C++:
void * List_t ::operator new (size_t )
#if !Global_ERWIN_DEFAULT_NEW_DELETE
static void operator delete (void * , size_t )
C++:
void List_t ::operator delete (void * , size_t )
#if !Global_ERWIN_DEFAULT_NEW_DELETE
static void * operator new[] (size_t )
C++:
void * List_t ::operator new[] (size_t )
#if !Global_ERWIN_DEFAULT_NEW_DELETE
static void operator delete[] (void * , size_t )
C++:
void List_t ::operator delete[] (void * , size_t )
[constructor] List ()
Creation
static List_t const & static_zero ()
#if List_DYN_ZERO
void _constructor ()
C++:
void List_t ::_constructor ()
void _destructor ()
C++:
void List_t ::_destructor ()
#if !Global_ERWIN_GLOBAL_ERRNO
int get_errno () const
C++:
int List_t ::get_errno () const
#if !Global_ERWIN_GLOBAL_ERRNO
void clear_errno () const
C++:
void List_t ::clear_errno () const
C:
void List_clear_errno (List_t const * self )
If you compiled Erwin with Global_ERWIN_THREAD_SAFE, this is the way
to get the status code of a given list.
If you do not
have a thread-safe Erwin library, there is a macro with the same name as
this function.
Error Codes (Global_list_errno)
In case of operation, Global_LIST_OK is signalled.
#if Global_ERWIN_GLOBAL_ERRNO
static int get_errno ()
#if Global_ERWIN_GLOBAL_ERRNO
static void clear_errno ()
C++:
void List_t ::clear_errno ()
Deletes everything in the list and the list structure itself.
List_delete is NULL safe (self may be NULL without crash or failed
assertion).
Assignment
[destructor] ~List ()
Destruction
operator List_t const * () const
C++:
List_t ::operator List_t const * () const
Conversion to C type
operator List_t * ()
C++:
List_t ::operator List_t * ()
Returns the position of the first element or List_KEY_ZERO if the list is empty
Returns the position of the last element or List_KEY_ZERO if the list is empty
Returns the previous element in the list or NULL if non exists.
If key == Global_LIST_KEY_ZERO, List_back () is returned.
Returns the next element in the list or NULL if non exists
If key == Global_LIST_KEY_ZERO, List_front () is returned.
Returns the key of the nth element or the zero element.
Returns LIST_ZERO if the element does not exist.
Returns the nth element or the zero element.
Erases an new element from the list. NEVER use this function
to modify a list you are currently iterating! Use
List_erase_in_loop for that.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
After this invocation, the key handle becomes invalid. Do not use
it anymore!
Erases an new element from the list when you are inside an iterator.
A pointer to an iterator is provided to this function for changing if
necessary. The 'reverse' argument specifies whether you are running
forward (false) or backward (true) over the list.
The pointer to the iterator must be != NULL.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Note that this function not only works in the standard iterators defined
in this file, but also in your own loops that you implement using e.g.
List_front (), List_next () or List_back (), List_previous (). In these lists,
too, you can pass the iterator to List_erase_in_loop ().
After this invocation, the key handle becomes invalid. Do not use
it anymore!
Erases an new element from the list when you are inside an iterator.
A pointer to an iterator is provided to this function for changing if
necessary. The 'reverse' argument specifies whether you are running
forward (false) or backward (true) over the list.
The pointer to the iterator must be != NULL.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Note that this function not only works in the standard iterators defined
in this file, but also in your own loops that you implement using e.g.
List_front (), List_next () or List_back (), List_previous (). In these lists,
too, you can pass the iterator to List_erase_in_loop ().
After this invocation, the key handle becomes invalid. Do not use
it anymore!
Returns the value for the given key or the zero element.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Returns the first element or the zero element if no first element exists.
Returns the last element or the zero element.
Returns a pointer to the value for the given key or NULL.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Returns a pointer to the value for the given key or NULL.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Appends a new element to the list (and copies it if necessary)
Preprends a new element to the list (and copies it if necessary)
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_append is invoked.
Sets the values of the given key. This overwrites the old value.
Invocation is only valid for key != Global_LIST_KEY_ZERO.
Inserts a new element into the list after or before a given one.
If pos is List_KEY_ZERO, then List_append or List_prepend is invoked.
This is the combined functionality of append, prepend, insert_after, insert_before.
Appends a new element to the list (and copies it if necessary)
List_t & append_list (List_t const * x )
Appends a new element to the list (and copies it if necessary)
List_t & append_list (List_t const & x )
Appends a new element to the list (and copies it if necessary)
List_t & prepend_list (List_t const * x )
Preprends a new element to the list (and copies it if necessary)
List_t & prepend_list (List_t const & x )
Preprends a new element to the list (and copies it if necessary)
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_append is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_append is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
#if List_DIRECT_RECURSION == 0
Appends a new element to the list (and copies it if necessary)
#if List_DIRECT_RECURSION == 0
Appends a new element to the list (and copies it if necessary)
#if List_DIRECT_RECURSION == 0
Preprends a new element to the list (and copies it if necessary)
#if List_DIRECT_RECURSION == 0
Preprends a new element to the list (and copies it if necessary)
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_append is invoked.
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_append is invoked.
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
#if List_DIRECT_RECURSION == 0
Inserts a new element into the list after the given one.
If pos is List_KEY_ZERO, then List_prepend is invoked.
bool next_iteration_reverse (Global_list_key_t * a , oType * b ) const
int nentries () const
C++:
int List_t ::nentries () const
C:
int List_nentries (List_t const * self )
Returns the number of entries in the list.
Note
If you compile lists to use minimal space, then
no element counter is implemented. In this case,
this is slow, it has to iterate the whole list.
The #define to determine whether an element counter
is not implemented is List_SLOW_NENTRIES, which is 0 by
default.
bool empty () const
C++:
bool List_t ::empty () const
C:
Global_ERWIN_BOOL List_empty (List_t const * self )
Returns whether the list contains no elements.
bool non_empty () const
C++:
bool List_t ::non_empty () const
C:
Global_ERWIN_BOOL List_empty (List_t const * self )
Returns whether the list contains no elements.
Occurrences of List_t
List_t const * Global_erwin_ptr_const_of (List_t const * x )
List_t const * Global_erwin_ptr_const_of (List_t const & x )
List_t * Global_erwin_ptr_of (List_t * x )
List_t * Global_erwin_ptr_of (List_t & x )
Global_list_key_t List_append (List_t * self , oTypeTouched value )
void List_append_list (List_t * self , List_t const * values )
Global_list_key_t List_back (List_t const * self )
void List_clear (List_t * self )
void List_clear_errno (List_t const * self )
int List_cmp (List_t const * , List_t const * , List_cmp_t cmp )
List_t * List_copy (List_t const * self )
List_t * List_copy_err (List_t const * self , int * err )
void List_delete (List_t * self )
Global_ERWIN_BOOL List_empty (List_t const * self )
void List_erase (List_t * self , Global_list_key_t key )
void List_erase_in_loop (Global_list_key_t * iterator , List_t * self , Global_list_key_t key , Global_ERWIN_BOOL reverse )
int List_errno (List_t const * )
oTypeResult List_first (List_t const * self )
Global_list_key_t List_front (List_t const * self )
Global_hashval_t List_hash (List_t const * )
Global_hashval_t List_hash (List_t const * x )
Global_hashval_t List_hash_raw (List_t const * )
Global_list_key_t List_insert (List_t * self , Global_list_key_t pos , oTypeTouched value , Global_ERWIN_BOOL backward )
Global_list_key_t List_insert_after (List_t * self , Global_list_key_t pos , oTypeTouched value )
Global_list_key_t List_insert_before (List_t * self , Global_list_key_t pos , oTypeTouched value )
void List_insert_list (List_t * self , Global_list_key_t pos , List_t const * values , Global_ERWIN_BOOL backward )
void List_insert_list_after (List_t * self , Global_list_key_t pos , List_t const * values )
void List_insert_list_before (List_t * self , Global_list_key_t pos , List_t const * values )
oTypeResult List_last (List_t const * self )
void List_map (List_t * self , List_map_t map )
int List_nentries (List_t const * self )
List_t * List_new ()
List_t * List_new_with_zero (oTypeTouched zero )
Global_list_key_t List_next (List_t const * self , Global_list_key_t key )
Global_ERWIN_BOOL List_next_iteration (List_t const * self , Global_list_key_t * key , oType * valuep )
Global_ERWIN_BOOL List_next_iteration_ptr (List_t * self , Global_list_key_t * key , oTypeVar * * valuepp )
Global_ERWIN_BOOL List_next_iteration_ptr_reverse (List_t * self , Global_list_key_t * key , oTypeVar * * valuepp )
Global_ERWIN_BOOL List_next_iteration_reverse (List_t const * self , Global_list_key_t * key , oType * valuep )
oTypeResult List_nth (List_t const * self , int index )
Global_list_key_t List_nth_key (List_t const * self , int index )
void List_overwrite (List_t * self , Global_list_key_t key , oTypeTouched value )
Global_list_key_t List_prepend (List_t * self , oTypeTouched value )
void List_prepend_list (List_t * self , List_t const * values )
Global_list_key_t List_previous (List_t const * self , Global_list_key_t key )
oTypeResult List_value (List_t const * self , Global_list_key_t key )
List_element_ptr_t List_value_ptr (List_t const * self , Global_list_key_t key )
oTypeResult List_zero (List_t const * self )
List_t const & List_t ::static_zero ()
List_t ::List ()
List_t ::List (oTypeTouched )
List_t ::operator List_t * ()
List_t ::operator List_t const * () const
bool List_t ::operator!= (List_t const & b ) const
bool List_t ::operator!= (List_t const * b ) const
bool List_t ::operator< (List_t const & b ) const
bool List_t ::operator< (List_t const * b ) const
List_t & List_t ::operator<< (oTypeTouched o )
bool List_t ::operator<= (List_t const & b ) const
bool List_t ::operator<= (List_t const * b ) const
List_t & List_t ::operator= (List_t const & )
List_t & List_t ::operator= (List_t const * )
bool List_t ::operator== (List_t const & b ) const
bool List_t ::operator== (List_t const * b ) const
bool List_t ::operator> (List_t const & b ) const
bool List_t ::operator> (List_t const * b ) const
bool List_t ::operator>= (List_t const & b ) const
bool List_t ::operator>= (List_t const * b ) const
List_t & List_t ::append (List_t const * x )
List_t & List_t ::append (List_t const & x )
List_t & List_t ::append_list (List_t const * x )
List_t & List_t ::append_list (List_t const & x )
List_t & List_t ::clear ()
int List_t ::cmp (List_t const * other , List_cmp_t cmp = List_CMP_T_NULL ) const
int List_t ::cmp (List_t const & other , List_cmp_t cmp_func = List_CMP_T_NULL ) const
List_t & List_t ::insert (Global_list_key_t k , List_t const * x , bool backwards )
List_t & List_t ::insert (Global_list_key_t k , List_t const & x , bool backwards )
List_t & List_t ::insert_after (Global_list_key_t k , List_t const * x )
List_t & List_t ::insert_after (Global_list_key_t k , List_t const & x )
List_t & List_t ::insert_before (Global_list_key_t k , List_t const * x )
List_t & List_t ::insert_before (Global_list_key_t k , List_t const & x )
List_t & List_t ::insert_list (Global_list_key_t k , List_t const * x , bool backwards )
List_t & List_t ::insert_list (Global_list_key_t k , List_t const & x , bool backwards )
List_t & List_t ::insert_list_after (Global_list_key_t k , List_t const * x )
List_t & List_t ::insert_list_after (Global_list_key_t k , List_t const & x )
List_t & List_t ::insert_list_before (Global_list_key_t k , List_t const * x )
List_t & List_t ::insert_list_before (Global_list_key_t k , List_t const & x )
List_t & List_t ::prepend (List_t const * x )
List_t & List_t ::prepend (List_t const & x )
List_t & List_t ::prepend_list (List_t const * x )
List_t & List_t ::prepend_list (List_t const & x )