Tizen Native API
|
Functions | |
Eina_List * | eina_list_append (Eina_List *list, const void *data) |
Appends the given data to the given linked list. | |
Eina_List * | eina_list_prepend (Eina_List *list, const void *data) |
Prepends the given data to the given linked list. | |
Eina_List * | eina_list_append_relative (Eina_List *list, const void *data, const void *relative) |
Inserts the given data into the given linked list after the specified data. | |
Eina_List * | eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) |
Appends a list node to a linked list after the specified member. | |
Eina_List * | eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) |
Prepends a data pointer to a linked list before the specified member. | |
Eina_List * | eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) |
Prepends a list node to a linked list before the specified member. | |
Eina_List * | eina_list_sorted_insert (Eina_List *list, Eina_Compare_Cb func, const void *data) |
Inserts a new node into a sorted list. | |
Eina_List * | eina_list_remove (Eina_List *list, const void *data) |
Removes the first instance of the specified data from the given list. | |
Eina_List * | eina_list_remove_list (Eina_List *list, Eina_List *remove_list) |
Removes the specified list node. | |
Eina_List * | eina_list_promote_list (Eina_List *list, Eina_List *move_list) |
Moves the specified data to the head of the list. | |
Eina_List * | eina_list_demote_list (Eina_List *list, Eina_List *move_list) |
Moves the specified data to the tail of the list. | |
void * | eina_list_data_find (const Eina_List *list, const void *data) |
Finds a member of a list and returns the member. | |
Eina_List * | eina_list_data_find_list (const Eina_List *list, const void *data) |
Finds a member of a list and returns the list node containing that member. | |
Eina_Bool | eina_list_move (Eina_List **to, Eina_List **from, void *data) |
Moves a data pointer from one list to another. | |
Eina_Bool | eina_list_move_list (Eina_List **to, Eina_List **from, Eina_List *data) |
Moves a list node from one list to another. | |
Eina_List * | eina_list_free (Eina_List *list) |
Frees an entire list and all the nodes, ignoring the data contained. | |
void * | eina_list_nth (const Eina_List *list, unsigned int n) |
Gets the nth member's data pointer in a list. | |
Eina_List * | eina_list_nth_list (const Eina_List *list, unsigned int n) |
Gets the nth member's list node in a list. | |
Eina_List * | eina_list_reverse (Eina_List *list) |
Reverses all the elements in the list. | |
Eina_List * | eina_list_reverse_clone (const Eina_List *list) |
Clones (copies) all the elements in the list in the reverse order. | |
Eina_List * | eina_list_clone (const Eina_List *list) |
Clones (copies) all the elements in the list in the exactly same order. | |
Eina_List * | eina_list_sort (Eina_List *list, unsigned int limit, Eina_Compare_Cb func) |
Sorts a list according to the ordering that func returns. | |
Eina_List * | eina_list_merge (Eina_List *left, Eina_List *right) |
Merges two lists. | |
Eina_List * | eina_list_sorted_merge (Eina_List *left, Eina_List *right, Eina_Compare_Cb func) |
Merges two sorted lists according to the ordering that func returns. | |
Eina_List * | eina_list_split_list (Eina_List *list, Eina_List *relative, Eina_List **right) |
Splits a list into 2 lists. | |
Eina_List * | eina_list_search_sorted_near_list (const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp) |
Returns the node nearest to data in the sorted list. | |
Eina_List * | eina_list_search_sorted_list (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns the node if data is in the sorted list. | |
void * | eina_list_search_sorted (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns the node data if it is in the sorted list. | |
Eina_List * | eina_list_search_unsorted_list (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns the node if data is in the unsorted list. | |
void * | eina_list_search_unsorted (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns the node data if it is in the unsorted list. | |
static Eina_List * | eina_list_last (const Eina_List *list) |
Gets the last list node in the list. | |
static Eina_List * | eina_list_next (const Eina_List *list) |
Gets the next list node after the specified list node. | |
static Eina_List * | eina_list_prev (const Eina_List *list) |
Gets the previous list node before the specified list node. | |
static void * | eina_list_data_get (const Eina_List *list) |
Gets the list node data member. | |
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_Iterator * | eina_list_iterator_new (const Eina_List *list) |
Returns a new iterator associated to a list. | |
Eina_Iterator * | eina_list_iterator_reversed_new (const Eina_List *list) |
Returns a new reversed iterator associated to a list. | |
Eina_Accessor * | eina_list_accessor_new (const Eina_List *list) |
Returns a new accessor associated to a list. | |
Typedefs | |
typedef struct _Eina_List | Eina_List |
The structure type for a generic double linked list. | |
typedef struct _Eina_List_Accounting | Eina_List_Accounting |
The structure type of the cache used to store the last element of a list and the number of elements, for fast access. | |
Defines | |
#define | EINA_LIST_FOREACH(list, l, data) |
Definition of the macro to iterate over a list. | |
#define | EINA_LIST_REVERSE_FOREACH(list, l, data) |
Definition of the macro to iterate over a list in the reverse order. | |
#define | EINA_LIST_FOREACH_SAFE(list, l, l_next, data) |
Definition of the macro to iterate over a list with support for node deletion. | |
#define | EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) |
Definition of the macro to iterate over a list in the reverse order with support for deletion. | |
#define | EINA_LIST_FREE(list, data) |
Definition of the macro to remove each list node while having access to each node's data. |
This group discusses the functions that provide double linked list management.
#define EINA_LIST_FOREACH | ( | list, | |
l, | |||
data | |||
) |
for (l = list, \ data = eina_list_data_get(l); \ l; \ l = eina_list_next(l), \ data = eina_list_data_get(l))
Definition of the macro to iterate over a list.
This macro iterates over list from the first element to the last. data is the data related to the current element. l is an Eina_List used as the list iterator.
It can be used to free list data, as in the following example:
Eina_List *list; Eina_List *l; char *data; // list is already filled, // its elements are just duplicated strings, // EINA_LIST_FOREACH will be used to free those strings EINA_LIST_FOREACH(list, l, data) free(data); eina_list_free(list);
list | The list to iterate over |
l | A list that is used as an iterator and points to the current node |
data | The current item's data |
#define EINA_LIST_FOREACH_SAFE | ( | list, | |
l, | |||
l_next, | |||
data | |||
) |
for (l = list, \ l_next = eina_list_next(l), \ data = eina_list_data_get(l); \ l; \ l = l_next, \ l_next = eina_list_next(l), \ data = eina_list_data_get(l))
Definition of the macro to iterate over a list with support for node deletion.
This macro iterates over list from the first element to the last. data is the data related to the current element. l is an Eina_List used as the list iterator.
This macro can be used to free list nodes, as in the following example:
Eina_List *list; Eina_List *l; Eina_List *l_next; char *data; // list is already filled, // its elements are just duplicated strings, // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key". EINA_LIST_FOREACH_SAFE(list, l, l_next, data) if (strcmp(data, "key") == 0) { free(data); list = eina_list_remove_list(list, l); }
list | The list to iterate over |
l | A list that is used as an iterator and points to the current node |
l_next | A list that is used as an iterator and points to the next node |
data | The current item's data |
#define EINA_LIST_FREE | ( | list, | |
data | |||
) |
for (data = eina_list_data_get(list); \ list; \ list = eina_list_remove_list(list, list), \ data = eina_list_data_get(list))
Definition of the macro to remove each list node while having access to each node's data.
This macro calls eina_list_remove_list for each list node and stores the data contained in the current node in data.
If you do not need to release node data, it is easier to call eina_list_free().
Eina_List *list; char *data; // list is already filled, // its elements are just duplicated strings, EINA_LIST_FREE(list, data) free(data);
list | The list that is cleared |
data | The current node's data |
#define EINA_LIST_REVERSE_FOREACH | ( | list, | |
l, | |||
data | |||
) |
for (l = eina_list_last(list), \ data = eina_list_data_get(l); \ l; \ l = eina_list_prev(l), \ data = eina_list_data_get(l))
Definition of the macro to iterate over a list in the reverse order.
This macro works like EINA_LIST_FOREACH, but iterates from the last element of a list to the first. data is the data related to the current element, while l is an Eina_List that is used as the list iterator.
It can be used to free list data, as in the following example:
Eina_List *list; Eina_List *l; char *data; // list is already filled, // its elements are just duplicated strings, // EINA_LIST_REVERSE_FOREACH will be used to free those strings EINA_LIST_REVERSE_FOREACH(list, l, data) free(data); eina_list_free(list);
list | The list to iterate over |
l | A list that is used as an iterator and points to the current node |
data | The current item's data |
#define EINA_LIST_REVERSE_FOREACH_SAFE | ( | list, | |
l, | |||
l_prev, | |||
data | |||
) |
for (l = eina_list_last(list), \ l_prev = eina_list_prev(l), \ data = eina_list_data_get(l); \ l; \ l = l_prev, \ l_prev = eina_list_prev(l), \ data = eina_list_data_get(l))
Definition of the macro to iterate over a list in the reverse order with support for deletion.
This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the last element of a list to the first. data is the data related to the current element, while l is an Eina_List that is used as the list iterator.
This macro can be used to free list nodes, as in the following example:
Eina_List *list; Eina_List *l; Eina_List *l_prev; char *data; // list is already filled, // its elements are just duplicated strings, // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that match "key". EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) if (strcmp(data, "key") == 0) { free(data); list = eina_list_remove_list(list, l); }
list | The list to iterate over |
l | A list that is used as an iterator and points to the current node |
l_prev | A list that is used as an iterator and points to the previous node |
data | The current item's data |
Eina_Accessor* eina_list_accessor_new | ( | const Eina_List * | list | ) |
Returns a new accessor associated to a list.
This function returns a newly allocated accessor associated to list. If list is NULL
or the count member of list is less than or equal to 0, this function returns NULL
.
NULL
is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid accessor is returned.[in] | list | The list |
Eina_List* eina_list_append | ( | Eina_List * | list, |
const void * | data | ||
) |
Appends the given data to the given linked list.
This function appends data to list. If list is NULL
, a new list is returned. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
Eina_List *list = NULL; extern void *my_data; list = eina_list_append(list, my_data); if (eina_error_get()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); }
[in] | list | The given list |
[in] | data | The data to append |
Eina_List* eina_list_append_relative | ( | Eina_List * | list, |
const void * | data, | ||
const void * | relative | ||
) |
Inserts the given data into the given linked list after the specified data.
This function inserts data to list after relative. If relative is not in the list, data is appended to the end of the list. If list is NULL
, a new list is returned. If there are multiple instances of relative in the list, data is inserted after the first instance.On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
Eina_List *list = NULL; extern void *my_data; extern void *relative_member; list = eina_list_append(list, relative_member); if (eina_error_get()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); } list = eina_list_append_relative(list, my_data, relative_member); if (eina_error_get()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); }
[in] | list | The given linked list |
[in] | data | The data to insert |
[in] | relative | The data to insert after |
Eina_List* eina_list_append_relative_list | ( | Eina_List * | list, |
const void * | data, | ||
Eina_List * | relative | ||
) |
Appends a list node to a linked list after the specified member.
This function inserts data to list after the list node relative. If list or relative is NULL
, data is just appended to list using eina_list_append(). If list is NULL
, a new list is returned. If there are multiple instances of relative in the list, data is inserted after the first instance. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
[in] | list | The given linked list |
[in] | data | The data to insert |
[in] | relative | The list node to insert after |
Eina_List* eina_list_clone | ( | const Eina_List * | list | ) |
Clones (copies) all the elements in the list in the exactly same order.
This function clones in an order which is same as the order of all the elements in list. If list is NULL
, this functon returns NULL
. This returns a copy of the given list.
[in] | list | The list to clone |
static unsigned int eina_list_count | ( | const Eina_List * | list | ) | [static] |
Gets the count of the number of items in a list.
This function returns the number of members that list contains. If the list is NULL
, 0
is returned.
[in] | list | The list whose count to return |
void* eina_list_data_find | ( | const Eina_List * | list, |
const void * | data | ||
) |
Finds a member of a list and returns the member.
This function searches in list from beginning to end for the first member whose data pointer is data. If it is found, data is returned, otherwise NULL
is returned.
Example:
extern Eina_List *list; extern void *my_data; if (eina_list_data_find(list, my_data) == my_data) { printf("Found member %p\n", my_data); }
[in] | list | The list to search for data |
[in] | data | The data pointer to find in the list |
NULL
Eina_List* eina_list_data_find_list | ( | const Eina_List * | list, |
const void * | data | ||
) |
Finds a member of a list and returns the list node containing that member.
This function searches in list from beginning to end for the first member whose data pointer is data. If it is found, the list node containing the specified member is returned, otherwise NULL
is returned.
[in] | list | The list to search for data |
[in] | data | The data pointer to find in the list |
NULL
static void* eina_list_data_get | ( | const Eina_List * | list | ) | [static] |
Gets the list node data member.
This function returns the data member of the specified list node list. It is equivalent to list->data. If list
is NULL
, this function returns NULL
.
[in] | list | The list node to get the data member of |
static void* eina_list_data_set | ( | Eina_List * | list, |
const void * | data | ||
) | [static] |
Sets the list node data member.
This function sets the data member data of the specified list node list. It returns the previous data of the node. If list is NULL
, this function returns NULL
.
[in] | list | The list node to get the data member of |
[in] | data | The data member for the list node |
Eina_List* eina_list_demote_list | ( | Eina_List * | list, |
Eina_List * | move_list | ||
) |
Moves the specified data to the tail of the list.
This function moves move_list to the back of list. If the list is NULL
, NULL
is returned. If move_list is NULL
, list is returned. Otherwise, a new list pointer that should be used in place of the one passed to this function is returned.
Example:
extern Eina_List *list; Eina_List *l; extern void *my_data; void *data; EINA_LIST_FOREACH(list, l, data) { if (data == my_data) { list = eina_list_demote_list(list, l); break; } }
[in] | list | The list handle to move the data |
[in] | move_list | The list node to move |
Eina_List* eina_list_free | ( | Eina_List * | list | ) |
Frees an entire list and all the nodes, ignoring the data contained.
This function frees all the nodes of list. It does not free the data of the nodes. To free them, use EINA_LIST_FREE.
[in] | list | The list to free |
NULL
pointer Eina_Iterator* eina_list_iterator_new | ( | const Eina_List * | list | ) |
Returns a new iterator associated to a list.
This function returns a newly allocated iterator associated to list. If list is NULL
or the count member of list is less than or equal to 0
, this function still returns a valid iterator that always returns false
on eina_iterator_next(), thus keeping the API sane.
NULL
is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is returned.[in] | list | The list |
Eina_Iterator* eina_list_iterator_reversed_new | ( | const Eina_List * | list | ) |
Returns a new reversed iterator associated to a list.
This function returns a newly allocated iterator associated to list. If list is NULL
or the count member of list is less than or equal to 0, this function still returns a valid iterator that always returns false
on eina_iterator_next(), thus keeping the API sane.
NULL
is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is returned.[in] | list | The list |
static Eina_List* eina_list_last | ( | const Eina_List * | list | ) | [static] |
Gets the last list node in the list.
This function returns the last list node in the list list. If list is NULL
or empty, NULL
is returned.
[in] | list | The list to get the last list node from |
Eina_List* eina_list_merge | ( | Eina_List * | left, |
Eina_List * | right | ||
) |
Merges two lists.
This function puts right at the end of left and returns the head. Both left and right do not exist anymore after the merge.
[in] | left | The head list to merge |
[in] | right | The tail list to merge |
Eina_Bool eina_list_move | ( | Eina_List ** | to, |
Eina_List ** | from, | ||
void * | data | ||
) |
Moves a data pointer from one list to another.
This function is a shortcut for doing the following: to = eina_list_append(to, data); from = eina_list_remove(from, data);
[out] | to | The list to move the data to |
[out] | from | The list to move from |
[in] | data | The data to move |
EINA_TRUE
on success, otherwise EINA_FALSE
Eina_Bool eina_list_move_list | ( | Eina_List ** | to, |
Eina_List ** | from, | ||
Eina_List * | data | ||
) |
Moves a list node from one list to another.
This function is a shortcut for doing the following: to = eina_list_append(to, data->data); from = eina_list_remove_list(from, data);
[out] | to | The list to move the data to |
[out] | from | The list to move from |
[in] | data | The list node containing the data to move |
EINA_TRUE
on success, otherwise EINA_FALSE
static Eina_List* eina_list_next | ( | const Eina_List * | list | ) | [static] |
Gets the next list node after the specified list node.
This function returns the next list node after the current one in list. It is equivalent to list->next. If list is NULL
or if no next list node exists, it returns NULL
.
[in] | list | The list node to get the next list node from |
NULL
void* eina_list_nth | ( | const Eina_List * | list, |
unsigned int | n | ||
) |
Gets the nth member's data pointer in a list.
This function returns the data pointer of element number n, in the list. The first element in the array is element number 0. If the element number n does not exist, NULL
is returned. Otherwise, the data of the found element is returned.
[in] | list | The list to get the specified member number from |
[in] | n | The number of the element (0 being the first) |
Eina_List* eina_list_nth_list | ( | const Eina_List * | list, |
unsigned int | n | ||
) |
Gets the nth member's list node in a list.
This function returns the list node of element number n, in list. The first element in the array is element number 0. If the element number n does not exist or list is NULL
, or n is greater than the count of the elements in list minus 1, NULL
is returned. Otherwise the list node stored in the numbered element is returned.
[in] | list | The list to get the specfied member number from |
[in] | n | The number of the element (0 being the first) |
Eina_List* eina_list_prepend | ( | Eina_List * | list, |
const void * | data | ||
) |
Prepends the given data to the given linked list.
This function prepends data to list. If list is NULL
, a new list is returned. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
Example:
Eina_List *list = NULL; extern void *my_data; list = eina_list_prepend(list, my_data); if (eina_error_get()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); }
[in] | list | The given list |
[in] | data | The data to prepend. |
Eina_List* eina_list_prepend_relative | ( | Eina_List * | list, |
const void * | data, | ||
const void * | relative | ||
) |
Prepends a data pointer to a linked list before the specified member.
This function inserts data to list before relative. If relative is not in the list, data is prepended to the list with eina_list_prepend(). If list is NULL
, a new list is returned. If there are multiple instances of relative in the list, data is inserted before the first instance. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
Eina_List *list = NULL; extern void *my_data; extern void *relative_member; list = eina_list_append(list, relative_member); if (eina_error_get_error()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); } list = eina_list_prepend_relative(list, my_data, relative_member); if (eina_error_get()) { fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); exit(-1); }
[in] | list | The given linked list |
[in] | data | The data to insert |
[in] | relative | The data to insert before |
Eina_List* eina_list_prepend_relative_list | ( | Eina_List * | list, |
const void * | data, | ||
Eina_List * | relative | ||
) |
Prepends a list node to a linked list before the specified member.
This function inserts data to list before the list node relative. If list or relative is NULL
, data is just prepended to list using eina_list_prepend(). If list is NULL
, a new list is returned. If there are multiple instances of relative in the list, data is inserted before the first instance. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
[in] | list | The given linked list |
[in] | data | The data to insert |
[in] | relative | The list node to insert before |
static Eina_List* eina_list_prev | ( | const Eina_List * | list | ) | [static] |
Gets the previous list node before the specified list node.
This function returns the previous list node before the current one in list. It is equivalent to list->prev. If list is NULL
or if no previous list node exists, it returns NULL
.
[in] | list | The list node to get the previous list node from |
NULL
if no previous list node exists Eina_List* eina_list_promote_list | ( | Eina_List * | list, |
Eina_List * | move_list | ||
) |
Moves the specified data to the head of the list.
This function moves move_list to the front of list. If the list is NULL
, NULL
is returned. If move_list is NULL
, list is returned. Otherwise, a new list pointer that should be used in place of the one passed to this function is returned.
Example:
extern Eina_List *list; Eina_List *l; extern void *my_data; void *data; EINA_LIST_FOREACH(list, l, data) { if (data == my_data) { list = eina_list_promote_list(list, l); break; } }
[in] | list | The list handle to move the data |
[in] | move_list | The list node to move |
Eina_List* eina_list_remove | ( | Eina_List * | list, |
const void * | data | ||
) |
Removes the first instance of the specified data from the given list.
This function removes the first instance of data from list. If the specified data is not in the given list (this includes the case where data is NULL
), nothing is done and the specified list is returned. If list is NULL
, NULL
is returned, otherwise a new list pointer that should be used in place of the one passed to this function is returned.
[in] | list | The given list |
[in] | data | The specified data |
Eina_List* eina_list_remove_list | ( | Eina_List * | list, |
Eina_List * | remove_list | ||
) |
Removes the specified list node.
This function removes the list node remove_list from list and frees the list node structure remove_list. If list is NULL
, this function returns NULL
. If remove_list is NULL
, it returns list, otherwise, a new list pointer that should be used in place of the one passed to this function is returned.
extern Eina_List *list; Eina_List *l; extern void *my_data; void *data EINA_LIST_FOREACH(list, l, data) { if (data == my_data) { list = eina_list_remove_list(list, l); break; } }
[in] | list | The given linked list |
[in] | remove_list | The list node to be removed |
Eina_List* eina_list_reverse | ( | Eina_List * | list | ) |
Reverses all the elements in the list.
This function reverses the order of all the elements in list, so the last member is now first, and so on. If list is NULL
, this function returns NULL
.
[in] | list | The list to reverse |
Eina_List* eina_list_reverse_clone | ( | const Eina_List * | list | ) |
Clones (copies) all the elements in the list in the reverse order.
This function reverses the order of all the elements in list, so the last member is now first, and so on. If list is NULL
, this function returns NULL
. This returns a copy of the given list.
[in] | list | The list to reverse |
void* eina_list_search_sorted | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns the node data if it is in the sorted list.
Example: Imagine a user gives a string, you check if it's in the list before duplicating its contents.
[in] | list | The list to search for data, must be sorted |
[in] | func | A function pointer that can handle comparing the list data nodes. |
[in] | data | The reference value to search |
node->data
) if func(node->data, data) == 0, otherwise NULL
if not foundEina_List* eina_list_search_sorted_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns the node if data is in the sorted list.
Example: Imagine a user gives a string, you check if it's in the list before duplicating its contents.
[in] | list | The list to search for data, must be sorted |
[in] | func | A function pointer that can handle comparing the list data nodes |
[in] | data | The reference value to search |
NULL
if not foundEina_List* eina_list_search_sorted_near_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data, | ||
int * | result_cmp | ||
) |
Returns the node nearest to data in the sorted list.
This function searches for a node containing data as its data in list, if such a node exists it is returned and result_cmp is 0
. If the data of no node in list is equal to data, the node with the nearest value to that is returned and result_cmp is the return value of func with data and the returned node's data as arguments.
void *ptr = eina_list_data_find(list, "my data"); if (!ptr) eina_list_sorted_insert(list, "my data");
int cmp_result; l = eina_list_search_sorted_near_list(list, cmp_func, "my data", &cmp_result); if (cmp_result > 0) list = eina_list_prepend_relative_list(list, "my data", l); else if (cmp_result < 0) list = eina_list_append_relative_list(list, "my data", l);
If cmp_result is 0 the element is already in the list and we need not insert it, if cmp_result is greater than zero "my @a data" needs to come after l(the nearest node present), if less than zero it needs to come before.
[in] | list | The list to search for data, must be sorted |
[in] | func | A function pointer that can handle comparing the list data nodes |
[in] | data | The reference value to search |
[in] | result_cmp | If provided it returns the result of the func(node->data, data) node being the last (returned) node. If node is found (exact match), then it is 0 . If the returned node is smaller than the requested data, it is less than 0 and if it's bigger it's greater than 0 . It is the last value returned by func(). |
NULL
if not foundvoid* eina_list_search_unsorted | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns the node data if it is in the unsorted list.
Example: Imagine a user gives a string, you check if it's in the list before duplicating its contents.
[in] | list | The list to search for data, may be unsorted |
[in] | func | A function pointer that can handle comparing the list data nodes |
[in] | data | The reference value to search. |
node->data
) if func(node->data, data) == 0, otherwise NULL
if not foundEina_List* eina_list_search_unsorted_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns the node if data is in the unsorted list.
Example: Imagine a user gives a string, you check if it's in the list before duplicating its contents.
[in] | list | The list to search for data, may be unsorted |
[in] | func | A function pointer that can handle comparing the list data nodes |
[in] | data | The reference value to search |
NULL
if not foundEina_List* eina_list_sort | ( | Eina_List * | list, |
unsigned int | limit, | ||
Eina_Compare_Cb | func | ||
) |
Sorts a list according to the ordering that func returns.
This function sorts list. If limit is 0
or greater than the number of elements in list, all the elements are sorted. func is used to compare two elements of list. If func is NULL
, this function returns list.
Example:
int sort_cb(const void *d1, const void *d2) { const char *txt = d1; const char *txt2 = d2; if(!txt) return(1); if(!txt2) return(-1); return(strcmp(txt, txt2)); } extern Eina_List *list; list = eina_list_sort(list, eina_list_count(list), sort_cb);
[in] | list | The list handle to sort |
[in] | limit | The maximum number of list elements to sort |
[in] | func | A function pointer that can handle comparing the list data nodes |
Eina_List* eina_list_sorted_insert | ( | Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Inserts a new node into a sorted list.
This function inserts values into a linked list assuming it is sorted and the result is sorted. If list is NULLL
, a new list is returned. On success, a new list pointer that should be used in place of the one given to this function is returned. Otherwise, the old pointer is returned.
[in] | list | The given linked list, must be sorted |
[in] | func | The function called for the sort |
[in] | data | The data to insert in the sorted list |
Eina_List* eina_list_sorted_merge | ( | Eina_List * | left, |
Eina_List * | right, | ||
Eina_Compare_Cb | func | ||
) |
Merges two sorted lists according to the ordering that func returns.
This function compares the head of left and right, and chooses the smallest one to be the head of the returned list. It continues this process for all the entries of both the lists.
Both the left and the right lists are not vaild anymore after the merge and should not be used. If func is NULL
, it returns NULL
.
Example:
int sort_cb(void *d1, void *d2) { const char *txt = NULL; const char *txt2 = NULL; if(!d1) return(1); if(!d2) return(-1); return(strcmp((const char*)d1, (const char*)d2)); } extern Eina_List *sorted1; extern Eina_List *sorted2; list = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
[in] | left | The first list to merge |
[in] | right | The second list to merge |
[in] | func | A function pointer that can handle comparing the list data nodes |
Eina_List* eina_list_split_list | ( | Eina_List * | list, |
Eina_List * | relative, | ||
Eina_List ** | right | ||
) |
Splits a list into 2 lists.
This function splits list into two lists ( left and right ) after the node relative. relative becomes the last node of the left list. If list or right is NULL
, list is returned. If relative is NULL
, right is set to list and NULL
is returned. If relative is the last node of list, list is returned and right is set to NULL
.
List does not exist anymore after the split.
[in] | list | The list to split |
[in] | relative | The list is split after relative |
[out] | right | The head of the new right list |