Loading...
Searching...
No Matches
datastructures.h File Reference
`#include <stddef.h>`
`#include <stdbool.h>`
`#include <sys/types.h>`
`#include <glib.h>`
`#include "macros.h"`
`#include "types.h"`
Include dependency graph for datastructures.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions

girara_list_t * | girara_list_new (void) GIRARA_VISIBLE
girara_list_t * | girara_list_new_with_free (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_new_with_free (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
void | girara_list_set_nth (girara_list_t *list, size_t n, void *data) 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

## Function Documentation

## girara_list_append()

void girara_list_append | ( | girara_list_t * | list,
|  | void * | data )

Append an element to the list.

Parameters

  list | The girara list object
  data | The element

## girara_list_clear()

void girara_list_clear | ( | girara_list_t * | list | ) |

Remove all elements from a list.

Parameters

  list | The girara list object

## girara_list_contains()

bool girara_list_contains | ( | girara_list_t * | list,
|  | void * | data )

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()

void * girara_list_find | ( | const girara_list_t * | list,
|  | girara_compare_function_t | compare,
|  | const void * | data )

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()

void girara_list_foreach | ( | girara_list_t * | list,
|  | girara_list_callback_t | callback,
|  | void * | data )

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()

void girara_list_free | ( | girara_list_t * | list | ) |

Destroy list.

Parameters

  list | The girara list object

## girara_list_iterator()

girara_list_iterator_t * girara_list_iterator | ( | girara_list_t * | list | ) |

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()

girara_list_iterator_t * girara_list_iterator_copy | ( | girara_list_iterator_t * | iter | ) |

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()

void * girara_list_iterator_data | ( | girara_list_iterator_t * | iter | ) |

Get data from the element pointed to by the iterator.

Parameters

  iter | The list iterator

Returns
  The data of the current element

## girara_list_iterator_free()

void girara_list_iterator_free | ( | girara_list_iterator_t * | iter | ) |

Destroy the iterator.

Parameters

  iter | The list iterator

## girara_list_iterator_has_next()

bool girara_list_iterator_has_next | ( | girara_list_iterator_t * | iter | ) |

Check if iterator has next element.

Parameters

  iter | The list iterator

Returns
  true if iterator has a next element, false otherwise

## girara_list_iterator_has_previous()

bool girara_list_iterator_has_previous | ( | girara_list_iterator_t * | iter | ) |

Check if iterator has previous element.

Parameters

  iter | The list iterator

Returns
  true if iterator has a previous element, false otherwise

## girara_list_iterator_is_valid()

bool girara_list_iterator_is_valid | ( | girara_list_iterator_t * | iter | ) |

Check if iterator is valid

Parameters

  iter | The list iterator

Returns
  true if iterator is valid, false otherwise

## girara_list_iterator_next()

girara_list_iterator_t * girara_list_iterator_next | ( | girara_list_iterator_t * | iter | ) |

Move iterator to next element.

Parameters

  iter | The list iterator

Returns
  The moved iterator or NULL if an error occurred

## girara_list_iterator_previous()

girara_list_iterator_t * girara_list_iterator_previous | ( | girara_list_iterator_t * | iter | ) |

Move iterator to previous element.

Parameters

  iter | The list iterator

Returns
  The moved iterator or NULL if an error occurred

## girara_list_iterator_remove()

void girara_list_iterator_remove | ( | girara_list_iterator_t * | iter | ) |

Remove element pointed by the iterator, and updates the iterator to the next element

Parameters

  iter | The list iterator

## girara_list_iterator_set()

void girara_list_iterator_set | ( | girara_list_iterator_t * | iter,
|  | void * | data )

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()

girara_list_t * girara_list_merge | ( | girara_list_t * | list,
|  | girara_list_t * | other )

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()

girara_list_t * girara_list_new | ( | void |  | ) |

Create a new list.

Returns
  The girara list object or NULL if an error occurred

## girara_list_new_with_free()

girara_list_t * girara_list_new_with_free | ( | girara_free_function_t | gfree | ) |

Create a new list with a free function.

Parameters

  gfree | Pointer to the free function

Returns
  The girara list object or NULL if an error occurred.

## girara_list_nth()

void * girara_list_nth | ( | girara_list_t * | list,
|  | size_t | n )

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()

void girara_list_prepend | ( | girara_list_t * | list,
|  | void * | data )

Prepend an element to the list.

Parameters

  list | The girara list object
  data | The element

## girara_list_remove()

void girara_list_remove | ( | girara_list_t * | list,
|  | void * | data )

Remove an element of the list

Parameters

  list | The girara list object
  data | The element

## girara_list_set_free_function()

void girara_list_set_free_function | ( | girara_list_t * | list,
|  | girara_free_function_t | gfree )

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_set_nth()

void girara_list_set_nth | ( | girara_list_t * | list,
|  | size_t | n,
|  | void * | data )

Replaces the nth entry

Parameters

  list | The girara list object
  n | Index of the entry
  data | The new entry

## girara_list_size()

size_t girara_list_size | ( | girara_list_t * | list | ) |

Get size of the list.

Parameters

  list | The girara list object

Returns
  The size of the list

## girara_list_sort()

void girara_list_sort | ( | girara_list_t * | list,
|  | girara_compare_function_t | compare )

Sort a list

Parameters

  list | The list to sort
  compare | compare function

## girara_node_append()

void girara_node_append | ( | girara_tree_node_t * | parent,
|  | girara_tree_node_t * | child )

Append a node to another node.

Parameters

  parent | The parent node
  child | The child node

## girara_node_append_data()

girara_tree_node_t * girara_node_append_data | ( | girara_tree_node_t * | parent,
|  | void * | 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()

void girara_node_free | ( | girara_tree_node_t * | node | ) |

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()

girara_list_t * girara_node_get_children | ( | girara_tree_node_t * | node | ) |

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()

void * girara_node_get_data | ( | girara_tree_node_t * | node | ) |

Get data.

Parameters

  node | The girara node object

Returns
  The data of the node

## girara_node_get_num_children()

size_t girara_node_get_num_children | ( | girara_tree_node_t * | node | ) |

Get number of children.

Parameters

  node | The girara node object

Returns
  The number of child nodes

## girara_node_get_parent()

girara_tree_node_t * girara_node_get_parent | ( | girara_tree_node_t * | node | ) |

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()

girara_tree_node_t * girara_node_get_root | ( | girara_tree_node_t * | node | ) |

Get root node.

Parameters

  node | The girara node object

Returns
  The root node or NULL if an error occurred

## girara_node_new()

girara_tree_node_t * girara_node_new | ( | void * | data | ) |

Create a new node.

Parameters

  data | Data of the new node

Returns
  A girara node object or NULL if an error occurred

## girara_node_set_data()

void girara_node_set_data | ( | girara_tree_node_t * | node,
|  | void * | data )

Set data.

Parameters

  node | The girara node object
  data | The new data of the object

## girara_node_set_free_function()

void girara_node_set_free_function | ( | girara_tree_node_t * | node,
|  | girara_free_function_t | gfree )

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()

girara_list_t * girara_sorted_list_new | ( | girara_compare_function_t | cmp | ) |

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_new_with_free()

girara_list_t * girara_sorted_list_new_with_free | ( | girara_compare_function_t | cmp,
|  | girara_free_function_t | gfree )

Create a new (sorted) list with a free function.

Parameters

  cmp | Pointer to the compare function.
  gfree | Pointer to the free function

Returns
  The girara list object or NULL if an error occurred.