#include <stddef.h>
#include <stdbool.h>
#include <sys/types.h>
#include "macros.h"
#include "types.h"
Go to the source code of this file.
|
#define | GIRARA_LIST_FOREACH(list, type, iter, data) |
|
#define | GIRARA_LIST_FOREACH_END(list, type, iter, data) |
|
#define | GIRARA_LIST_FOREACH_BODY_WITH_ITER(list, type, iter, data, ...) |
|
#define | GIRARA_LIST_FOREACH_BODY(list, type, data, ...) |
|
|
girara_list_t * | girara_list_new (void) GIRARA_VISIBLE |
|
girara_list_t * | girara_list_new2 (girara_free_function_t gfree) GIRARA_VISIBLE |
|
girara_list_t * | girara_sorted_list_new (girara_compare_function_t cmp) GIRARA_VISIBLE |
|
girara_list_t * | girara_sorted_list_new2 (girara_compare_function_t cmp, girara_free_function_t gfree) GIRARA_VISIBLE |
|
void | girara_list_set_free_function (girara_list_t *list, girara_free_function_t gfree) GIRARA_VISIBLE |
|
void | girara_list_clear (girara_list_t *list) GIRARA_VISIBLE |
|
void | girara_list_free (girara_list_t *list) GIRARA_VISIBLE |
|
void | girara_list_append (girara_list_t *list, void *data) GIRARA_VISIBLE |
|
void | girara_list_prepend (girara_list_t *list, void *data) GIRARA_VISIBLE |
|
void | girara_list_remove (girara_list_t *list, void *data) GIRARA_VISIBLE |
|
void * | girara_list_nth (girara_list_t *list, size_t n) GIRARA_VISIBLE |
|
bool | girara_list_contains (girara_list_t *list, void *data) GIRARA_VISIBLE |
|
size_t | girara_list_size (girara_list_t *list) GIRARA_VISIBLE |
|
ssize_t | girara_list_position (girara_list_t *list, void *data) GIRARA_VISIBLE |
|
void | girara_list_sort (girara_list_t *list, girara_compare_function_t compare) GIRARA_VISIBLE |
|
void * | girara_list_find (const girara_list_t *list, girara_compare_function_t compare, const void *data) GIRARA_VISIBLE |
|
girara_list_iterator_t * | girara_list_iterator (girara_list_t *list) GIRARA_VISIBLE |
|
girara_list_iterator_t * | girara_list_iterator_copy (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
girara_list_iterator_t * | girara_list_iterator_next (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
bool | girara_list_iterator_has_next (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
girara_list_iterator_t * | girara_list_iterator_previous (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
bool | girara_list_iterator_has_previous (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
void | girara_list_iterator_remove (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
bool | girara_list_iterator_is_valid (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
void * | girara_list_iterator_data (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
void | girara_list_iterator_set (girara_list_iterator_t *iter, void *data) GIRARA_VISIBLE |
|
void | girara_list_iterator_free (girara_list_iterator_t *iter) GIRARA_VISIBLE |
|
void | girara_list_foreach (girara_list_t *list, girara_list_callback_t callback, void *data) GIRARA_VISIBLE |
|
girara_list_t * | girara_list_merge (girara_list_t *list, girara_list_t *other) GIRARA_VISIBLE |
|
girara_tree_node_t * | girara_node_new (void *data) GIRARA_VISIBLE |
|
void | girara_node_set_free_function (girara_tree_node_t *node, girara_free_function_t gfree) GIRARA_VISIBLE |
|
void | girara_node_free (girara_tree_node_t *node) GIRARA_VISIBLE |
|
void | girara_node_append (girara_tree_node_t *parent, girara_tree_node_t *child) GIRARA_VISIBLE |
|
girara_tree_node_t * | girara_node_append_data (girara_tree_node_t *parent, void *data) GIRARA_VISIBLE |
|
girara_tree_node_t * | girara_node_get_parent (girara_tree_node_t *node) GIRARA_VISIBLE |
|
girara_tree_node_t * | girara_node_get_root (girara_tree_node_t *node) GIRARA_VISIBLE |
|
girara_list_t * | girara_node_get_children (girara_tree_node_t *node) GIRARA_VISIBLE |
|
size_t | girara_node_get_num_children (girara_tree_node_t *node) GIRARA_VISIBLE |
|
void * | girara_node_get_data (girara_tree_node_t *node) GIRARA_VISIBLE |
|
void | girara_node_set_data (girara_tree_node_t *node, void *data) GIRARA_VISIBLE |
|
◆ GIRARA_LIST_FOREACH
#define GIRARA_LIST_FOREACH |
( |
|
list, |
|
|
|
type, |
|
|
|
iter, |
|
|
|
data |
|
) |
| |
Value: do { \
girara_list_iterator_t * girara_list_iterator(girara_list_t *list) GIRARA_VISIBLE
void * girara_list_iterator_data(girara_list_iterator_t *iter) GIRARA_VISIBLE
bool girara_list_iterator_is_valid(girara_list_iterator_t *iter) GIRARA_VISIBLE
Definition at line 244 of file datastructures.h.
◆ GIRARA_LIST_FOREACH_BODY
#define GIRARA_LIST_FOREACH_BODY |
( |
|
list, |
|
|
|
type, |
|
|
|
data, |
|
|
|
... |
|
) |
| |
Value:
#define GIRARA_LIST_FOREACH_END(list, type, iter, data)
#define GIRARA_LIST_FOREACH(list, type, iter, data)
Definition at line 261 of file datastructures.h.
◆ GIRARA_LIST_FOREACH_BODY_WITH_ITER
#define GIRARA_LIST_FOREACH_BODY_WITH_ITER |
( |
|
list, |
|
|
|
type, |
|
|
|
iter, |
|
|
|
data, |
|
|
|
... |
|
) |
| |
◆ GIRARA_LIST_FOREACH_END
#define GIRARA_LIST_FOREACH_END |
( |
|
list, |
|
|
|
type, |
|
|
|
iter, |
|
|
|
data |
|
) |
| |
Value:
} \
girara_list_iterator_free(iter); \
} while(0)
girara_list_iterator_t * girara_list_iterator_next(girara_list_iterator_t *iter) GIRARA_VISIBLE
Definition at line 250 of file datastructures.h.
◆ girara_list_append()
Append an element to the list.
- Parameters
-
list | The girara list object |
data | The element |
◆ girara_list_clear()
Remove all elements from a list.
- Parameters
-
list | The girara list object |
◆ girara_list_contains()
Checks if the list contains the given element
- Parameters
-
list | The girara list object |
data | The element |
- Returns
- true if the list contains the element
◆ girara_list_find()
Find an element
- Parameters
-
list | The list |
compare | compare function |
data | data passed as the second argument to the compare function |
- Returns
- the element if found or NULL
◆ girara_list_foreach()
Call function for each element in the list.
- Parameters
-
list | The list |
callback | The function to call. |
data | Passed to the callback as second argument. |
◆ girara_list_free()
Destroy list.
- Parameters
-
list | The girara list object |
◆ girara_list_iterator()
Create an iterator pointing at the start of list.
- Parameters
-
list | The girara list object |
- Returns
- The list iterator or NULL if an error occurred
◆ girara_list_iterator_copy()
Create an iterator pointing to the same element as iter.
- Parameters
-
iter | The girara list iterator to be copied |
- Returns
- The list iterator or NULL if an error occurred
◆ girara_list_iterator_data()
Get data from the element pointed to by the iterator.
- Parameters
-
- Returns
- The data of the current element
◆ girara_list_iterator_free()
Destroy the iterator.
- Parameters
-
◆ girara_list_iterator_has_next()
Check if iterator has next element.
- Parameters
-
- Returns
- true if iterator has a next element, false otherwise
◆ girara_list_iterator_has_previous()
Check if iterator has previous element.
- Parameters
-
- Returns
- true if iterator has a previous element, false otherwise
◆ girara_list_iterator_is_valid()
Check if iterator is valid
- Parameters
-
- Returns
- true if iterator is valid, false otherwise
◆ girara_list_iterator_next()
Move iterator to next element.
- Parameters
-
- Returns
- The moved iterator or NULL if an error occurred
◆ girara_list_iterator_previous()
Move iterator to previous element.
- Parameters
-
- Returns
- The moved iterator or NULL if an error occurred
◆ girara_list_iterator_remove()
Remove element pointed by the iterator, and updates the iterator to the next element
- Parameters
-
◆ girara_list_iterator_set()
Set data from the element pointed to by the iterator.
- Parameters
-
iter | The list iterator |
data | Sets the list iterator to a specific element |
◆ girara_list_merge()
Merge a list into another one. Both lists need to have the same free function. If other has a source free function set it will be set to NULL as the elements then belong to list.
- Parameters
-
list | the target list |
other | the source list |
- Returns
- list with the elements from other.
◆ girara_list_new()
Create a new list.
- Returns
- The girara list object or NULL if an error occurred
◆ girara_list_new2()
Create a new list.
- Parameters
-
gfree | Pointer to the free function |
- Returns
- The girara list object or NULL if an error occurred.
◆ girara_list_nth()
Returns nth entry
- Parameters
-
list | The girara list object |
n | Index of the entry |
- Returns
- The nth element or NULL if an error occurred
◆ girara_list_position()
ssize_t girara_list_position |
( |
girara_list_t * |
list, |
|
|
void * |
data |
|
) |
| |
Returns the position of the element in the list
- Parameters
-
list | The girara list object |
data | The element |
- Returns
- The position or -1 if the data is not found
◆ girara_list_prepend()
Prepend an element to the list.
- Parameters
-
list | The girara list object |
data | The element |
◆ girara_list_remove()
Remove an element of the list
- Parameters
-
list | The girara list object |
data | The element |
◆ girara_list_set_free_function()
Set the function which should be called if the stored data should be freed.
- Parameters
-
list | The girara list object |
gfree | Pointer to the free function |
◆ girara_list_size()
Get size of the list.
- Parameters
-
list | The girara list object |
- Returns
- The size of the list
◆ girara_list_sort()
Sort a list
- Parameters
-
list | The list to sort |
compare | compare function |
◆ girara_node_append()
Append a node to another node.
- Parameters
-
parent | The parent node |
child | The child node |
◆ girara_node_append_data()
Append data as new node to another node.
- Parameters
-
parent | The parent node |
data | The data of the node |
- Returns
- The node object or NULL if an error occurred
◆ girara_node_free()
Free a node. This will remove the node from its' parent and will destroy all its' children.
- Parameters
-
node | The girara node object |
◆ girara_node_get_children()
Get list of children.
- Parameters
-
node | The girara node object |
- Returns
- List object containing all child nodes or NULL if an error occurred
◆ girara_node_get_data()
Get data.
- Parameters
-
node | The girara node object |
- Returns
- The data of the node
◆ girara_node_get_num_children()
Get number of children.
- Parameters
-
node | The girara node object |
- Returns
- The number of child nodes
◆ girara_node_get_parent()
Get parent node.
- Parameters
-
node | The girara node object |
- Returns
- The parent node or NULL if an error occurred or no parent exists
◆ girara_node_get_root()
Get root node.
- Parameters
-
node | The girara node object |
- Returns
- The root node or NULL if an error occurred
◆ girara_node_new()
Create a new node.
- Parameters
-
- Returns
- A girara node object or NULL if an error occurred
◆ girara_node_set_data()
Set data.
- Parameters
-
node | The girara node object |
data | The new data of the object |
◆ girara_node_set_free_function()
Set the function which should be called if the stored data should be freed.
- Parameters
-
node | The girara node object |
gfree | Pointer to the free function |
◆ girara_sorted_list_new()
Create a new (sorted) list.
- Parameters
-
cmp | Pointer to the compare function. |
- Returns
- The girara list object or NULL if an error occurred.
◆ girara_sorted_list_new2()
Create a new (sorted) list.
- Parameters
-
cmp | Pointer to the compare function. |
gfree | Pointer to the free function |
- Returns
- The girara list object or NULL if an error occurred.