RLP
1.5
|
Implementation of a linked list. More...
Go to the source code of this file.
Data Structures | |
struct | SListNode |
Linked list node structure. More... | |
struct | SList |
Linked list structure. More... | |
Typedefs | |
typedef SListNode * | ListNode |
Linked list node definition. More... | |
typedef SList * | List |
Linked list definition. More... | |
Functions | |
List | newList (void) |
Creates a list. More... | |
void | listDelete (List list) |
Deletes a list. More... | |
int | listInsertFst (List list, void *value) |
Inserts an element at the beginning of a list. More... | |
int | listInsertLst (List list, void *value) |
Inserts an element at the end of a list. More... | |
int | listInsertAt (List list, int index, void *value) |
Inserts an new element at the specified position of a list. More... | |
int | listRemoveFst (List list, void **value) |
Removes the first element of a list. More... | |
int | listRemoveLst (List list, void **value) |
Removes the last element of a list. More... | |
int | listRemoveAt (List list, int index, void **value) |
Removes the element at the specified position of a list. More... | |
int | listFst (List list, void **value) |
Provides the value at the first position of a list. More... | |
int | listLst (List list, void **value) |
Provides the value at the last position of a list. More... | |
int | listAt (List list, int index, void **value) |
Provides the element at the specified position of a list. More... | |
int | listSize (List list) |
Returns the size of a list. More... | |
int | listMap (List list, void(*fun)(void *)) |
Applies a function to the elements of a list. More... | |
Iterator | listIterator (List list) |
Creates an iterator from a list. More... | |
Implementation of a linked list.
Provides functions to create and manipulate a linked list.
Definition in file list.h.
int listAt | ( | List | list, |
int | index, | ||
void ** | value | ||
) |
Provides the element at the specified position of a list.
If there is no element at the specified position, it will be put the value NULL
at value
.
value
a pointer to the value at the last position. Changes to this value will affect the element in the list.list | the list |
index | the index of the element to be provided |
value | pointer where the value at the specified position will be put |
void listDelete | ( | List | list | ) |
int listFst | ( | List | list, |
void ** | value | ||
) |
Provides the value at the first position of a list.
If the list is empty, it will be put the value NULL
at value
.
value
a pointer to the value at the first position. Changes to this value will affect the element in the list.list | the list |
value | pointer where the value at the first position will be put |
int listInsertAt | ( | List | list, |
int | index, | ||
void * | value | ||
) |
Inserts an new element at the specified position of a list.
The position, specified by argument index
, must be a non negative integer, and less than the current size of the list.
list | the list |
index | the index at which the new value is to be inserted |
value | the value to be inserted |
int listInsertFst | ( | List | list, |
void * | value | ||
) |
int listInsertLst | ( | List | list, |
void * | value | ||
) |
int listLst | ( | List | list, |
void ** | value | ||
) |
Provides the value at the last position of a list.
If the list is empty, it will be put the value NULL
at value
.
value
a pointer to the value at the last position. Changes to this value will affect the element in the list.list | the list |
value | pointer where the value at the last position will be put |
int listMap | ( | List | list, |
void(*)(void *) | fun | ||
) |
int listRemoveAt | ( | List | list, |
int | index, | ||
void ** | value | ||
) |
Removes the element at the specified position of a list.
Provides the value of the removed element if the value of value
is not NULL
.
list | the list. |
index | the index of the element to be removed |
value | pointer where the removed value should be put (or NULL ) |
index
was invalid int listRemoveFst | ( | List | list, |
void ** | value | ||
) |
Removes the first element of a list.
Provides the value of the removed element if the value of value
is not NULL
.
list | the list. |
value | pointer where the removed value should be put (or NULL ) |
int listRemoveLst | ( | List | list, |
void ** | value | ||
) |
Removes the last element of a list.
Provides the value of the removed element if the value of value
is not NULL
.
list | the list. |
value | pointer where the removed value should be put (or NULL ) |
int listSize | ( | List | list | ) |
RLP © 2006, 2009, 2015 Rui Carlos Gonçalves