If you don't know how to create lists see Adding elements to Eina_List.
This is the code we have already seen to create a list. Now if we need to search the list we can do it like this:
However if searching the list multiple times it probably is better to sort the list since the sorted_search functions are much faster:
Once the list is sorted it's not a good idea to use append/prepend functions since that would add the element in the wrong place, instead elements should be added with eina_list_sorted_insert():
A noteworthy use case is adding an element to a list only if it doesn't exist already, this can accomplished by searching for the element that is closest to what is being added, and if that doesn't match add:
It is sometimes useful to get a portion of the list as another list, here we take every element that comes after "boomer" and split it into "other_list":
It is also possible to add entire lists of elements using eina_list_sorted_merge():
And as always release memory and shutdown eina before ending:
The full source code can be found on the examples folder on the eina_list_02.c file.