lists.h File Reference
Go to the source code of this file.
Detailed Description
An efficient and expandable double-linked list implementation for any usage.
Define Documentation
| #define linked_walk |
( |
list, |
|
|
condition |
|
) |
|
Value:do { \
if((list) == NULL) { walk = NULL; break; } \
for(walk = (list); (walk->next != NULL) && (condition); walk = walk->next); \
if(!(condition)) walk = NULL; \
} while(0)
Walks a linked list.
Walks a linked list, checking for a condition, and saving the result in walk.
- Parameters:
-
| list | the list to walk. |
| condition | the condition to check each node for. Use walk as the node name. |
- Returns:
- A node named walk must be existant in the function this is called from. The node that matches the condition will be stored in walk, or NULL if no matching node could be found.
Function Documentation
| void* linked_add_after |
( |
void * |
l, |
|
|
void * |
n, |
|
|
void * |
node | |
|
) |
| | |
Adds a node after another in a list.
- Parameters:
-
| l | the list for the node to be added to. |
| n | the node to be added to the list. |
| node | the node of which n should come before. |
- Returns:
- The added node.
| void* linked_add_before |
( |
void * |
l, |
|
|
void * |
n, |
|
|
void * |
node | |
|
) |
| | |
Adds a node before another in a list.
- Parameters:
-
| l | the list for the node to be added to. |
| n | the node to be added to the list. |
| node | the node of which n should come after. |
- Returns:
- The added node.
| void* linked_add_first |
( |
void * |
l, |
|
|
void * |
n | |
|
) |
| | |
Adds a node to the beginning of a list.
- Parameters:
-
| l | the list for the node to be added to. |
| n | the node to be added to the list. |
- Returns:
- The added node.
| void* linked_add_last |
( |
void * |
l, |
|
|
void * |
n | |
|
) |
| | |
Adds a node to the end of a list.
- Parameters:
-
| l | the list for the node to be added to. |
| n | the node to be added to the list. |
- Returns:
- The added node.
| void linked_del |
( |
void * |
l, |
|
|
void * |
node | |
|
) |
| | |
Deletes a node from a list.
- Parameters:
-
| l | the list for the node to be added to. |
| node | the node to be removed from the list. |
Creates a list node.
Allocates a piece of memory with a specified size, and returns it as a node.
- Parameters:
-
| size | the size of the nodes data (something like the size of your node might be a good idea). |
- Returns:
- A linked_node with the memory size specified.