Public interface for a DLlist class. More...
#include <DLlist.h>
Related Functions | |
(Note that these are not member functions.) | |
void | DLlist_append (DLlist_ptr self, void *element) |
Adds at the end of a list a new element. | |
DLlist_ptr | DLlist_copy (DLlist_ptr self) |
Creates a copy of a given list. | |
DLlist_ptr | DLlist_copy_reversed (DLlist_ptr self) |
Creates a copy of a given list with the order of elements reversed. | |
DLlist_ptr | DLlist_create (void) |
Creates an instance of a Two-dimentional List. | |
DLiter | DLlist_delete (DLlist_ptr self, DLiter iter, void **element) |
Removes an element pointed by an iterator from a list. | |
void * | DLlist_delete_first (DLlist_ptr self) |
Removes a first element of a list. | |
void * | DLlist_delete_last (DLlist_ptr self) |
Removes a last element of a list. | |
void | DLlist_destroy (DLlist_ptr self) |
Destroys a list instance. | |
DLiter | DLlist_end (DLlist_ptr self) |
Returns an iterator pointing past the last element of a list. | |
DLiter | DLlist_first (DLlist_ptr self) |
Returns an iterator pointing to the first element of a list. | |
int | DLlist_get_size (DLlist_ptr self) |
Returns the size of a list. | |
DLiter | DLlist_insert_after (DLlist_ptr self, DLiter iter, void *element) |
Insert a new element into the list "self" directly after an element pointed by "iter". | |
DLiter | DLlist_insert_before (DLlist_ptr self, DLiter iter, void *element) |
Insert a new element into the list "self" directly before an element pointed by "iter". | |
boolean | DLlist_is_empty (DLlist_ptr self) |
Returns true iff the list is empty. | |
void | DLlist_prepend (DLlist_ptr self, void *element) |
Adds at the beginning of a list a new element. | |
void | DLlist_reverse (DLlist_ptr self) |
Reverse the order of elements in the list. |
Public interface for a DLlist class.
Implementation of DLlist class
void DLlist_append | ( | DLlist_ptr | self, | |
void * | element | |||
) | [related] |
Adds at the end of a list a new element.
DLlist_ptr DLlist_copy | ( | DLlist_ptr | self | ) | [related] |
DLlist_ptr DLlist_copy_reversed | ( | DLlist_ptr | self | ) | [related] |
Creates a copy of a given list with the order of elements reversed.
Note: input list does not change
DLlist_ptr DLlist_create | ( | void | ) | [related] |
Creates an instance of a Two-dimentional List.
DLiter DLlist_delete | ( | DLlist_ptr | self, | |
DLiter | iter, | |||
void ** | element | |||
) | [related] |
Removes an element pointed by an iterator from a list.
Precondition: iter must point to elements of list "self" and NOT the past the last element of the list.
The element being removed is returned in argument *element (only if element != NULL).
Returns an iterator pointing to the element after removed one.
NOTE: all iterators equal to iter will become invalid. Any operations on them are prohibited. ADVICE: do not use several iterators over the same list if deletion operation is possible.
void * DLlist_delete_first | ( | DLlist_ptr | self | ) | [related] |
Removes a first element of a list.
The removed element is returned. Precondition: the list must not be empty.
void * DLlist_delete_last | ( | DLlist_ptr | self | ) | [related] |
Removes a last element of a list.
The removed element is returned. Precondition: the list must not be empty.
void DLlist_destroy | ( | DLlist_ptr | self | ) | [related] |
Destroys a list instance.
The memory used by the list will be freed. Note: memory occupied by the elements is not freed! It is the user responsibility.
DLiter DLlist_end | ( | DLlist_ptr | self | ) | [related] |
Returns an iterator pointing past the last element of a list.
For returned iterator function DLiter_is_end() will always return true and DLiter_is_first() will always return false.
NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: deletion the elements of the list may make the iterator invalid (see corresponding delete functions).
DLiter DLlist_first | ( | DLlist_ptr | self | ) | [related] |
Returns an iterator pointing to the first element of a list.
If the list is empty the iterator will point past the last element of a list (i.e. past the list). This means function DLiter_is_end() will return true in this case and DLiter_is_first() will return false.
NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: deletion the elements of the list may make the iterator invalid (see corresponding delete functions).
int DLlist_get_size | ( | DLlist_ptr | self | ) | [related] |
Returns the size of a list.
DLiter DLlist_insert_after | ( | DLlist_ptr | self, | |
DLiter | iter, | |||
void * | element | |||
) | [related] |
Insert a new element into the list "self" directly after an element pointed by "iter".
Precondition: iter must point to elements of list "self" and NOT past the last element of the list. If iter is not an iterator of list self there will be problems with memory which are usually very difficult to debug.
NOTE: after the function call all existing iterators (including iter) will point to the same element as before.
Returns an iterator pointing to the newly inserted element.
DLiter DLlist_insert_before | ( | DLlist_ptr | self, | |
DLiter | iter, | |||
void * | element | |||
) | [related] |
Insert a new element into the list "self" directly before an element pointed by "iter".
Precondition: iter must point to elements of list "self" or past the last element of the list.
If the iterator points past the last element of a list then this function is equivalent to calling DLlist_append(self, element).
NOTE: after the function call all existing iterators (including iter) will point to the same element as before.
Returns an iterator pointing to the newly inserted element.
boolean DLlist_is_empty | ( | DLlist_ptr | self | ) | [related] |
Returns true iff the list is empty.
void DLlist_prepend | ( | DLlist_ptr | self, | |
void * | element | |||
) | [related] |
Adds at the beginning of a list a new element.
void DLlist_reverse | ( | DLlist_ptr | self | ) | [related] |
Reverse the order of elements in the list.
Note: existing iterators pointing to the elements of the list remains the same and may be used later on