list.c File Reference
Implementation of the linked list.
More...
#include "list.h"
#include <stdlib.h>
#include <assert.h>
Go to the source code of this file.
|
Functions |
list * | newList () |
| Creates a new list.
|
void | deleteList (list *src) |
| Frees the memory for the list structure.
|
void | listAdd (list *src, const void *data) |
| Adds a new datum after the current position.
|
void | listRemove (list *src) |
| Removes the currently selected item.
|
void | listSet (list *src, const void *data) |
| Sets the datum at the currently selected index.
|
void * | listGet (list *src) |
| Returns the currently selected element.
|
int | listNext (list *src) |
| Advances the list one position and returns 0, if the end was reached.
|
void | listStart (list *src) |
| Sets the current element to the top.
|
int | listCount (list *src) |
| Counts the list.
|
int | listIsEmpty (list *src) |
| Returns 1 , if this list is empty, else 0 .
|
Detailed Description
Implementation of the linked list.
- Author:
- Dorian Weber
Definition in file list.c.
Function Documentation
void deleteList |
( |
list * |
src |
) |
|
Frees the memory for the list structure.
- Parameters:
-
Definition at line 34 of file list.c.
void listAdd |
( |
list * |
src, |
|
|
const void * |
data | |
|
) |
| | |
Adds a new datum after the current position.
- Parameters:
-
[in] | src | list to append |
[in] | data | pointer to store |
Definition at line 48 of file list.c.
int listCount |
( |
list * |
src |
) |
|
Counts the list.
- Parameters:
-
- Returns:
- number of items currently stored
Definition at line 107 of file list.c.
void* listGet |
( |
list * |
src |
) |
|
Returns the currently selected element.
- Precondition:
- A valid element is selected.
- Parameters:
-
[in] | src | list to retrieve data from |
- Returns:
- data pointer
Definition at line 84 of file list.c.
int listIsEmpty |
( |
list * |
src |
) |
|
Returns 1
, if this list is empty, else 0
.
Definition at line 122 of file list.c.
int listNext |
( |
list * |
src |
) |
|
Advances the list one position and returns 0, if the end was reached.
- Parameters:
-
Definition at line 90 of file list.c.
void listRemove |
( |
list * |
src |
) |
|
Removes the currently selected item.
- Precondition:
- A valid element is selected.
- Parameters:
-
[in] | src | list to remove from |
Definition at line 59 of file list.c.
void listSet |
( |
list * |
src, |
|
|
const void * |
data | |
|
) |
| | |
Sets the datum at the currently selected index.
- Precondition:
- A valid element is selected.
- Parameters:
-
[in] | src | list to set |
[in] | data | pointer to store |
Definition at line 76 of file list.c.
void listStart |
( |
list * |
src |
) |
|
Sets the current element to the top.
- Note:
- This is always one element before the first one.
- Parameters:
-
Definition at line 101 of file list.c.
Creates a new list.
- Returns:
- pointer to a new list
Definition at line 27 of file list.c.