Reordering Eina_List elements example
//Compile with:
//gcc -g eina_list_03.c -o eina_list_03 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int
main(int argc, char **argv)
{
(void)argc;
(void)argv;
Eina_List *list = NULL, *r_list;
void *list_data;
list = eina_list_append(list, "caprica");
list = eina_list_append(list, "sagittarius");
list = eina_list_append(list, "aerilon");
list = eina_list_append(list, "gemenon");
list = eina_list_demote_list(list, eina_list_nth_list(list, 2));
list = eina_list_remove(list, "sagittarius");
l = eina_list_data_find_list(list, "aerilon");
eina_list_data_set(l, "aquarius");
printf("size: %d\n", eina_list_count(list));
r_list = eina_list_reverse_clone(list);
itr = eina_list_iterator_new(r_list);
EINA_ITERATOR_FOREACH(itr, list_data)
printf("%s\n", (char*)list_data);
eina_list_free(r_list);
return 0;
}
Eina Utility library.
EINA_API void eina_iterator_free(Eina_Iterator *iterator)
Frees an iterator.
Definition: eina_iterator.c:98
#define EINA_ITERATOR_FOREACH(itr, data)
Definition for the macro to iterate over all elements easily.
Definition: eina_iterator.h:448
static void * eina_list_data_set(Eina_List *list, const void *data)
Sets the list node data member.
static unsigned int eina_list_count(const Eina_List *list)
Gets the count of the number of items in a list.
EINA_API Eina_List * eina_list_demote_list(Eina_List *list, Eina_List *move_list)
Moves the specified data to the tail of the list.
Definition: eina_list.c:889
EINA_API Eina_List * eina_list_nth_list(const Eina_List *list, unsigned int n)
Gets the nth member's list node in a list.
Definition: eina_list.c:1006
EINA_API Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition: eina_list.c:584
EINA_API Eina_List * eina_list_remove(Eina_List *list, const void *data)
Removes the first instance of the specified data from the given list.
Definition: eina_list.c:773
EINA_API Eina_List * eina_list_free(Eina_List *list)
Frees an entire list and all the nodes, ignoring the data contained.
Definition: eina_list.c:823
EINA_API Eina_Iterator * eina_list_iterator_new(const Eina_List *list)
Returns a new iterator associated with a list.
Definition: eina_list.c:1574
EINA_API Eina_List * eina_list_reverse_clone(const Eina_List *list)
Clones (copies) all the elements in the list in reverse order.
Definition: eina_list.c:1072
EINA_API Eina_List * eina_list_promote_list(Eina_List *list, Eina_List *move_list)
Moves the specified data to the head of the list.
Definition: eina_list.c:845
EINA_API Eina_List * eina_list_data_find_list(const Eina_List *list, const void *data)
Finds a member of a list and returns it as a list node.
Definition: eina_list.c:975
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
structure of an iterator
Definition: eina_iterator.h:159
Type for a generic double linked list.
Definition: eina_list.h:318