Commit 85cea4a0 authored by Sebastian Ramacher's avatar Sebastian Ramacher

implement girara_list_find

parent aa7ccbb1
......@@ -173,6 +173,23 @@ girara_list_contains(girara_list_t* list, void* data)
return true;
}
void*
girara_list_find(girara_list_t* list, girara_compare_function_t compare, const void* data)
{
g_return_val_if_fail(list && compare, NULL);
if (list->start == NULL) {
return NULL;
}
GList* element = g_list_find_custom(list->start, data, compare);
if (element == NULL) {
return NULL;
}
return element->data;
}
girara_list_iterator_t*
girara_list_iterator(girara_list_t* list)
{
......
......@@ -122,6 +122,17 @@ int girara_list_position(girara_list_t* list, void* data);
*/
void girara_list_sort(girara_list_t* list, girara_compare_function_t compare);
/**
* Find an element
*
* @param list The list
* @param compare compare function
* @param data data passed as the second argument to the compare function
* @return the element if found or NULL
*/
void* girara_list_find(girara_list_t* list, girara_compare_function_t compare,
const 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