Commit 9c571087 authored by Moritz Lipp's avatar Moritz Lipp

Implemented girara_list_position

parent 9b6be034
......@@ -191,6 +191,25 @@ size_t girara_list_size(girara_list_t* list)
return g_list_length(list->start);
}
int
girara_list_position(girara_list_t* list, void* data)
{
g_return_val_if_fail(list != NULL, -1);
if (list->start == NULL) {
return -1;
}
for (unsigned int i = 0; i < g_list_length(list->start); i++) {
GList* tmp = g_list_nth(list->start, i);
if (data == tmp->data) {
return i;
}
}
return -1;
}
girara_tree_node_t* girara_node_new(void* data)
{
......
......@@ -79,6 +79,15 @@ bool girara_list_contains(girara_list_t* list, void* data);
*/
size_t girara_list_size(girara_list_t* list);
/**
* Returns the position of the element in the list
*
* @param list The girara list object
* @param data The element
* @return The position or -1 if the data is not found
*/
int girara_list_position(girara_list_t* list, void* data);
/**
* Create an iterator pointing at the start of list.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment