These functions provide double linked list management. More...
Data Structures | |
struct | _Eina_List |
Type for a generic double linked list. More... | |
struct | _Eina_List_Accounting |
Cache used to store the last element of a list and the number of elements, for fast access. More... | |
Macros | |
#define | EINA_LIST_FOREACH(list, l, data) |
Macro to iterate over a list. More... | |
#define | EINA_LIST_REVERSE_FOREACH(list, l, data) |
Macro to iterate over a list in the reverse order. More... | |
#define | EINA_LIST_FOREACH_SAFE(list, l, l_next, data) |
Macro to iterate over a list with support for node deletion. More... | |
#define | EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) |
Macro to iterate over a list in the reverse order with support for deletion. More... | |
#define | EINA_LIST_FREE(list, data) |
Macro to remove each list node while having access to each node's data. More... | |
Typedefs | |
typedef struct _Eina_List | Eina_List |
Type for a generic double linked list. | |
typedef struct _Eina_List_Accounting | Eina_List_Accounting |
Cache used to store the last element of a list and the number of elements, for fast access. | |
Functions | |
Eina_List * | eina_list_append (Eina_List *list, const void *data) |
Append the given data to the given linked list. More... | |
Eina_List * | eina_list_prepend (Eina_List *list, const void *data) |
Prepends the given data to the given linked list. More... | |
Eina_List * | eina_list_append_relative (Eina_List *list, const void *data, const void *relative) |
Insert the given data into the given linked list after the specified data. More... | |
Eina_List * | eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) |
Append a list node to a linked list after the specified member. More... | |
Eina_List * | eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) |
Prepend a data pointer to a linked list before the specified member. More... | |
Eina_List * | eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) |
Prepend a list node to a linked list before the specified member. More... | |
Eina_List * | eina_list_sorted_insert (Eina_List *list, Eina_Compare_Cb func, const void *data) |
Insert a new node into a sorted list. More... | |
Eina_List * | eina_list_remove (Eina_List *list, const void *data) |
Remove the first instance of the specified data from the given list. More... | |
Eina_List * | eina_list_remove_list (Eina_List *list, Eina_List *remove_list) |
Remove the specified list node. More... | |
Eina_List * | eina_list_promote_list (Eina_List *list, Eina_List *move_list) |
Move the specified data to the head of the list. More... | |
Eina_List * | eina_list_demote_list (Eina_List *list, Eina_List *move_list) |
Move the specified data to the tail of the list. More... | |
void * | eina_list_data_find (const Eina_List *list, const void *data) |
Find a member of a list and return the member. More... | |
Eina_List * | eina_list_data_find_list (const Eina_List *list, const void *data) |
Find a member of a list and return the list node containing that member. More... | |
Eina_Bool | eina_list_move (Eina_List **to, Eina_List **from, void *data) |
Move a data pointer from one list to another. More... | |
Eina_Bool | eina_list_move_list (Eina_List **to, Eina_List **from, Eina_List *data) |
Move a list node from one list to another. More... | |
Eina_List * | eina_list_free (Eina_List *list) |
Free an entire list and all the nodes, ignoring the data contained. More... | |
void * | eina_list_nth (const Eina_List *list, unsigned int n) |
Get the nth member's data pointer in a list. More... | |
Eina_List * | eina_list_nth_list (const Eina_List *list, unsigned int n) |
Get the nth member's list node in a list. More... | |
Eina_List * | eina_list_reverse (Eina_List *list) |
Reverse all the elements in the list. More... | |
Eina_List * | eina_list_reverse_clone (const Eina_List *list) |
Clone (copy) all the elements in the list in reverse order. More... | |
Eina_List * | eina_list_clone (const Eina_List *list) |
Clone (copy) all the elements in the list in exactly same order. More... | |
Eina_List * | eina_list_sort (Eina_List *list, unsigned int limit, Eina_Compare_Cb func) |
Sort a list according to the ordering func will return. More... | |
Eina_List * | eina_list_shuffle (Eina_List *list, Eina_Random_Cb func) |
Shuffle list. More... | |
Eina_List * | eina_list_merge (Eina_List *left, Eina_List *right) |
Merge two list. More... | |
Eina_List * | eina_list_sorted_merge (Eina_List *left, Eina_List *right, Eina_Compare_Cb func) |
Merge two sorted list according to the ordering func will return. More... | |
Eina_List * | eina_list_split_list (Eina_List *list, Eina_List *relative, Eina_List **right) |
Split a list into 2 lists. More... | |
Eina_List * | eina_list_search_sorted_near_list (const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp) |
Returns node nearest to data is in the sorted list. More... | |
Eina_List * | eina_list_search_sorted_list (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns node if data is in the sorted list. More... | |
void * | eina_list_search_sorted (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns node data if it is in the sorted list. More... | |
Eina_List * | eina_list_search_unsorted_list (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns node if data is in the unsorted list. More... | |
void * | eina_list_search_unsorted (const Eina_List *list, Eina_Compare_Cb func, const void *data) |
Returns node data if it is in the unsorted list. More... | |
static Eina_List * | eina_list_last (const Eina_List *list) |
Get the last list node in the list. More... | |
static Eina_List * | eina_list_next (const Eina_List *list) |
Get the next list node after the specified list node. More... | |
static Eina_List * | eina_list_prev (const Eina_List *list) |
Get the previous list node before the specified list node. More... | |
static void * | eina_list_data_get (const Eina_List *list) |
Get the list node data member. More... | |
static void * | eina_list_data_set (Eina_List *list, const void *data) |
Set the list node data member. More... | |
static unsigned int | eina_list_count (const Eina_List *list) |
Get the count of the number of items in a list. More... | |
Eina_Iterator * | eina_list_iterator_new (const Eina_List *list) |
Returned a new iterator associated to a list. More... | |
Eina_Iterator * | eina_list_iterator_reversed_new (const Eina_List *list) |
Returned a new reversed iterator associated to a list. More... | |
Eina_Accessor * | eina_list_accessor_new (const Eina_List *list) |
Returned a new accessor associated to a list. More... | |
These functions provide double linked list management.
Eina_List is a doubly linked list. It can store data of any type in the form of void pointers. It has convenience functions to do all the common operations which means it should rarely if ever be necessary to directly access the struct's fields. Nevertheless it can be useful to understand the inner workings of the data structure being used.
Eina_List nodes keep references to the previous node, the next node, its data and to an accounting structure.
Eina_List_Accounting is used to improve the performance of some functions. It is private and should not be modified. It contains a reference to the end of the list and the number of elements in the list.
Most functions have two versions that have the same effect but operate on different arguments, the plain functions operate over data(eg.: eina_list_append_relative, eina_list_remove, eina_list_data_find), the list versions of these functions operate on Eina_List nodes.
Here are some examples of Eina_List usage:
#define EINA_LIST_FOREACH | ( | list, | |
l, | |||
data | |||
) |
Macro to iterate over a list.
list | The list to iterate over. |
l | A list that is used as an iterator and points to the current node. |
data | Current item's data. |
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.
The following diagram illustrates this macro iterating over a list of four elements("one", "two", "three" and "four"):
Full-size
It can be used to free list data, as in the following example:
list
must be a pointer to the first element of the list.Referenced by ecore_file_app_installed(), ecore_file_app_list(), ecore_file_path_dir_exists(), ecore_fork_reset(), ecore_fork_reset_callback_del(), ecore_getopt_callback_ecore_evas_list_engines(), ecore_imf_context_event_callback_call(), ecore_imf_context_input_panel_event_callback_call(), ecore_thread_cancel(), edje_available_modules_get(), edje_collection_cache_flush(), edje_collection_cache_set(), edje_edit_color_class_add(), edje_edit_color_class_colors_get(), edje_edit_color_class_colors_set(), edje_edit_color_class_del(), edje_edit_color_class_name_set(), edje_edit_color_classes_list_get(), edje_edit_group_del(), edje_edit_program_after_del(), edje_edit_program_afters_get(), edje_edit_program_target_del(), edje_edit_program_targets_get(), edje_edit_state_copy(), edje_edit_state_external_param_bool_get(), edje_edit_state_external_param_choice_get(), edje_edit_state_external_param_double_get(), edje_edit_state_external_param_get(), edje_edit_state_external_param_int_get(), edje_edit_state_external_param_set(), edje_edit_state_external_param_string_get(), edje_edit_style_tags_list_get(), edje_edit_styles_list_get(), edje_external_param_find(), edje_freeze(), edje_perspective_global_set(), edje_perspective_set(), edje_scale_set(), edje_thaw(), eeze_udev_find_similar_from_syspath(), eeze_udev_find_unlisted_similar(), efreet_desktop_command_local_get(), efreet_desktop_command_progress_get(), efreet_desktop_string_list_join(), efreet_icon_list_find(), efreet_menu_async_get(), efreet_menu_dump(), efreet_menu_get(), efreet_mime_globs_type_get(), efreet_trash_ls(), efreet_util_menus_find(), eina_file_map_faulted(), eina_list_append_relative(), eina_list_clone(), eina_list_data_find_list(), eina_list_prepend_relative(), eina_list_reverse_clone(), eina_list_search_unsorted_list(), evas_object_box_children_get(), evas_object_table_child_get(), evas_post_event_callback_remove(), evas_post_event_callback_remove_full(), evas_textblock_cursor_geometry_bidi_get(), and evas_textblock_style_set().
#define EINA_LIST_REVERSE_FOREACH | ( | list, | |
l, | |||
data | |||
) |
Macro to iterate over a list in the reverse order.
list | The list to iterate over. |
l | A list that is used as an iterator and points to the current node. |
data | Current item's data. |
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.
The following diagram illustrates this macro iterating over a list of four elements("one", "two", "three" and "four"):
Full-size
It can be used to free list data, as in the following example:
list
must be a pointer to the first element of the list.#define EINA_LIST_FOREACH_SAFE | ( | list, | |
l, | |||
l_next, | |||
data | |||
) |
Macro to iterate over a list with support for node deletion.
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 | Current item's data. |
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.
Since this macro stores a pointer to the next list node in l_next
, deleting the current node and continuing looping is safe.
The following diagram illustrates this macro iterating over a list of four elements("one", "two", "three" and "four"):
Full-size
This macro can be used to free list nodes, as in the following example:
list
must be a pointer to the first element of the list. Referenced by ecore_con_shutdown(), ecore_fork_reset(), ecore_imf_context_event_callback_del(), ecore_imf_context_input_panel_event_callback_del(), ecore_ipc_shutdown(), and edje_edit_program_del().
#define EINA_LIST_REVERSE_FOREACH_SAFE | ( | list, | |
l, | |||
l_prev, | |||
data | |||
) |
Macro to iterate over a list in the reverse order with support for deletion.
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 | Current item's data. |
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.
Since this macro stores a pointer to the previous list node in l_prev
, deleting the current node and continuing looping is safe.
The following diagram illustrates this macro iterating over a list of four elements("one", "two", "three" and "four"):
Full-size
This macro can be used to free list nodes, as in the following example:
list
must be a pointer to the first element of the list. #define EINA_LIST_FREE | ( | list, | |
data | |||
) |
Macro to remove each list node while having access to each node's data.
list | The list that will be cleared. |
data | Current node's data. |
This macro will call eina_list_remove_list for each list node, and store the data contained in the current node in data
.
The following diagram illustrates this macro iterating over a list of four elements("one", "two", "three" and "four"):
Full-size
If you do not need to release node data, it is easier to call eina_list_free().
list
must be a pointer to the first element of the list.Referenced by ecore_con_shutdown(), ecore_con_url_additional_headers_clear(), ecore_con_url_free(), ecore_con_url_shutdown(), ecore_file_app_list(), ecore_file_download_abort_all(), ecore_getopt_list_free(), ecore_imf_context_del(), ecore_ipc_server_del(), edje_available_modules_get(), edje_edit_program_del(), edje_edit_state_copy(), edje_thaw(), efreet_icon_list_find(), efreet_menu_free(), eina_benchmark_free(), ethumb_client_generate_cancel_all(), evas_device_del(), evas_render_method_list_free(), and evas_render_updates_free().
Append the given data to the given linked list.
list | The given list. |
data | The data to append. |
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.
The following example code demonstrates how to ensure that the given data has been successfully appended.
list
must be a pointer to the first element of the list(or NULL). References _Eina_List::accounting, _Eina_List::data, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by ecore_con_server_add(), ecore_con_server_connect(), ecore_con_socks4_remote_add(), ecore_con_socks5_remote_add(), ecore_con_url_additional_header_add(), ecore_evas_ecore_evas_list_get(), ecore_evas_ews_new(), ecore_evas_object_image_new(), ecore_fb_input_device_open(), ecore_file_app_list(), ecore_file_ls(), ecore_fork_reset_callback_add(), ecore_imf_context_event_callback_add(), ecore_imf_context_input_panel_event_callback_add(), ecore_ipc_server_add(), ecore_ipc_server_connect(), ecore_main_fd_handler_file_add(), ecore_main_fd_handler_prepare_callback_set(), ecore_thread_feedback_run(), ecore_thread_run(), edje_available_modules_get(), edje_edit_color_class_add(), edje_edit_color_classes_list_get(), edje_edit_data_list_get(), edje_edit_externals_list_get(), edje_edit_fonts_list_get(), edje_edit_group_data_list_get(), edje_edit_images_list_get(), edje_edit_part_states_list_get(), edje_edit_parts_list_get(), edje_edit_program_after_add(), edje_edit_program_afters_get(), edje_edit_program_target_add(), edje_edit_program_targets_get(), edje_edit_programs_list_get(), edje_edit_state_add(), edje_edit_state_copy(), edje_edit_state_external_param_set(), edje_edit_state_tweens_list_get(), edje_edit_style_add(), edje_edit_style_tag_add(), edje_edit_style_tags_list_get(), edje_edit_styles_list_get(), edje_mmap_collection_list(), edje_mmap_group_exists(), eet_eina_stream_data_descriptor_class_set(), eet_node_hash_new(), eet_node_list_append(), eeze_disk_eject(), eeze_disk_mount(), eeze_disk_new(), eeze_disk_new_from_mount(), eeze_disk_unmount(), eeze_net_list(), eeze_udev_find_by_filter(), eeze_udev_find_by_sysattr(), eeze_udev_find_by_type(), eeze_udev_syspath_get_parents(), efreet_desktop_category_add(), efreet_desktop_command_local_get(), efreet_desktop_command_progress_get(), efreet_desktop_string_list_parse(), efreet_desktop_type_add(), efreet_icon_list_find(), efreet_menu_desktop_insert(), efreet_menu_kde_legacy_init(), efreet_mime_type_icon_get(), efreet_util_desktop_categories_list(), efreet_util_desktop_exec_glob_list(), eina_benchmark_run(), eina_list_append_relative(), eina_list_append_relative_list(), eina_list_clone(), eina_list_move(), eina_list_move_list(), eina_list_sorted_insert(), eina_rectangle_pool_new(), eldbus_connection_event_callback_del(), eldbus_name_owner_changed_callback_del(), eldbus_object_event_callback_del(), eldbus_object_signal_handler_add(), eldbus_proxy_event_callback_del(), eldbus_proxy_signal_handler_add(), ethumb_client_generate_cancel(), ethumb_client_thumb_exists(), evas_device_add(), evas_device_parent_set(), evas_object_box_children_get(), evas_textblock_cursor_range_formats_get(), and evas_textblock_cursor_range_geometry_get().
Prepends the given data to the given linked list.
list | The given list. |
data | The data to prepend. |
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.
The following example code demonstrates how to ensure that the given data has been successfully prepended.
Example:
list
must be a pointer to the first element of the list. References _Eina_List::data, _Eina_List::next, and _Eina_List::prev.
Referenced by edje_edit_group_add(), eet_node_struct_child_new(), eeze_udev_find_similar_from_syspath(), efreet_icon_extension_add(), eina_list_prepend_relative(), eina_list_prepend_relative_list(), eina_list_reverse_clone(), evas_gl_context_create(), evas_gl_surface_create(), and evas_post_event_callback_push().
Insert the given data into the given linked list after the specified data.
list | The given linked list. |
data | The data to insert. |
relative | The data to insert after. |
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.
The following example code demonstrates how to ensure that the given data has been successfully inserted.
list
must be a pointer to the first element of the list. References eina_list_append(), eina_list_append_relative_list(), and EINA_LIST_FOREACH.
Referenced by efreet_menu_desktop_insert().
Eina_List* eina_list_append_relative_list | ( | Eina_List * | list, |
const void * | data, | ||
Eina_List * | relative | ||
) |
Append a list node to a linked list after the specified member.
list | The given linked list. |
data | The data to insert. |
relative | The list node to insert after. |
This function inserts data
to list
after the list node relative
. If list
or relative
are 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.
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List::data, eina_list_append(), _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by eina_list_append_relative(), and eina_list_sorted_insert().
Eina_List* eina_list_prepend_relative | ( | Eina_List * | list, |
const void * | data, | ||
const void * | relative | ||
) |
Prepend a data pointer to a linked list before the specified member.
list | The given linked list. |
data | The data to insert. |
relative | The data to insert before. |
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.
The following code example demonstrates how to ensure that the given data has been successfully inserted.
list
must be a pointer to the first element of the list. References EINA_LIST_FOREACH, eina_list_prepend(), and eina_list_prepend_relative_list().
Eina_List* eina_list_prepend_relative_list | ( | Eina_List * | list, |
const void * | data, | ||
Eina_List * | relative | ||
) |
Prepend a list node to a linked list before the specified member.
list | The given linked list. |
data | The data to insert. |
relative | The list node to insert before. |
This function inserts data
to list
before the list node relative
. If list
or relative
are 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.
list
must be a pointer to the first element of the list. References _Eina_List::data, eina_list_prepend(), _Eina_List::next, and _Eina_List::prev.
Referenced by eina_list_prepend_relative(), and eina_list_sorted_insert().
Eina_List* eina_list_sorted_insert | ( | Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Insert a new node into a sorted list.
list | The given linked list, must be sorted. |
func | The function called for the sort. |
data | The data to insert sorted. |
This function inserts values into a linked list assuming it was sorted and the result will be 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.
func
) average/worst case performance as it uses eina_list_search_sorted_near_list() and thus is bounded to that. As said in eina_list_search_sorted_near_list(), lists do not have O(1) access time, so walking to the correct node can be costly, consider worst case to be almost O(n) pointer dereference (list walk).list
must be a pointer to the first element of the list. References eina_list_append(), eina_list_append_relative_list(), eina_list_prepend_relative_list(), and eina_list_search_sorted_near_list().
Remove the first instance of the specified data from the given list.
list | The given list. |
data | The specified data. |
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
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.
list
must be a pointer to the first element of the list. References eina_list_data_find_list(), and eina_list_remove_list().
Referenced by ecore_con_socks4_remote_del(), ecore_con_socks5_remote_del(), ecore_con_socks_remote_del(), ecore_con_url_free(), ecore_fb_input_device_close(), ecore_file_download_abort(), ecore_imf_context_input_panel_event_callback_clear(), ecore_ipc_client_del(), ecore_ipc_server_del(), ecore_thread_feedback_run(), ecore_thread_run(), edje_edit_color_class_del(), edje_edit_string_list_free(), edje_edit_style_del(), edje_edit_style_tag_del(), edje_file_collection_list_free(), eeze_disk_free(), efreet_desktop_category_del(), efreet_menu_desktop_remove(), ethumb_client_thumb_exists_cancel(), evas_device_parent_set(), evas_gl_context_destroy(), evas_gl_surface_destroy(), and evas_textblock_cursor_free().
Remove the specified list node.
list | The given linked list. |
remove_list | The list node which is to be removed. |
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.
The following code gives an example (notice we use EINA_LIST_FOREACH instead of EINA_LIST_FOREACH_SAFE because we stop the loop after removing the current node).
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by ecore_fork_reset(), ecore_fork_reset_callback_del(), ecore_imf_context_event_callback_del(), ecore_imf_context_input_panel_event_callback_del(), ecore_thread_cancel(), edje_edit_group_del(), edje_edit_program_after_del(), edje_edit_program_afters_clear(), edje_edit_program_del(), edje_edit_program_target_del(), edje_edit_program_targets_clear(), efreet_mime_type_icon_get(), eina_list_move(), eina_list_move_list(), eina_list_remove(), and ethumb_client_generate_cancel().
Move the specified data to the head of the list.
list | The list handle to move the data. |
move_list | The list node to move. |
This function move move_list
to the front of list
. If 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.
Example:
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by efreet_icon_extension_add().
Move the specified data to the tail of the list.
list | The list handle to move the data. |
move_list | The list node to move. |
This function move move_list
to the back of list
. If 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.
Example:
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
void* eina_list_data_find | ( | const Eina_List * | list, |
const void * | data | ||
) |
Find a member of a list and return the member.
list | The list to search for a data. |
data | The data pointer to find in the list. |
NULL
otherwise.This function searches in list
from beginning to end for the first member whose data pointer is data
. If it is found, data
will be returned, otherwise NULL
will be returned.
Example:
list
must be a pointer to the first element of the list. References eina_list_data_find_list().
Referenced by ecore_main_fd_handler_prepare_callback_set().
Find a member of a list and return the list node containing that member.
list | The list to search for data. |
data | The data pointer to find in the list. |
NULL
otherwise.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.
list
must be a pointer to the first element of the list. References EINA_LIST_FOREACH.
Referenced by efreet_icon_extension_add(), eina_list_data_find(), eina_list_move(), and eina_list_remove().
Move a data pointer from one list to another.
to | The list to move the data to |
from | The list to move from |
data | The data to move |
This function is a shortcut for doing the following: to = eina_list_append(to, data); from = eina_list_remove(from, data);
list
must be a pointer to the first element of the list. References EINA_FALSE, eina_list_append(), eina_list_data_find_list(), eina_list_remove_list(), and EINA_TRUE.
Move a list node from one list to another.
to | The list to move the data to |
from | The list to move from |
data | The list node containing the data to move |
This function is a shortcut for doing the following: to = eina_list_append(to, data->data); from = eina_list_remove_list(from, data);
list
must be a pointer to the first element of the list. References _Eina_List::data, EINA_FALSE, eina_list_append(), eina_list_remove_list(), and EINA_TRUE.
Free an entire list and all the nodes, ignoring the data contained.
list | The list to free |
NULL
pointerThis function frees all the nodes of list
. It does not free the data of the nodes. To free them, use EINA_LIST_FREE.
References _Eina_List::next.
Referenced by ecore_audio_shutdown(), ecore_evas_engines_free(), edje_mmap_group_exists(), eet_eina_stream_data_descriptor_class_set(), efreet_desktop_command_progress_get(), and efreet_icon_list_find().
void* eina_list_nth | ( | const Eina_List * | list, |
unsigned int | n | ||
) |
Get the nth member's data pointer in a list.
list | The list to get the specified member number from. |
n | The number of the element (0 being the first). |
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.
list
must be a pointer to the first element of the list. References _Eina_List::data, and eina_list_nth_list().
Referenced by efreet_desktop_free(), efreet_desktop_get(), efreet_desktop_save(), efreet_desktop_type_alias(), and efreet_menu_desktop_insert().
Get the nth member's list node in a list.
list | The list to get the specfied member number from. |
n | The number of the element (0 being the first). |
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 elements in list
minus 1, NULL
is returned. Otherwise the list node stored in the numbered element is returned.
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by eina_list_nth(), and eina_list_sort().
Reverse all the elements in the list.
list | The list to reverse. |
This function reverses the order of all elements in list
, so the last member is now first, and so on. If list
is NULL
, this functon returns NULL
.
list
must be a pointer to the first element of the list.References _Eina_List::accounting, _Eina_List::data, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Clone (copy) all the elements in the list in reverse order.
list | The list to reverse. |
This function reverses the order of all elements in list
, so the last member is now first, and so on. If list
is NULL
, this functon returns NULL
. This returns a copy of the given list.
list
must be a pointer to the first element of the list.References EINA_LIST_FOREACH, and eina_list_prepend().
Clone (copy) all the elements in the list in exactly same order.
list | The list to clone. |
This function clone in order of all elements in list
. If list
is NULL
, this functon returns NULL
. This returns a copy of the given list.
list
must be a pointer to the first element of the list.References eina_list_append(), and EINA_LIST_FOREACH.
Referenced by ecore_evas_engines_get().
Eina_List* eina_list_sort | ( | Eina_List * | list, |
unsigned int | limit, | ||
Eina_Compare_Cb | func | ||
) |
Sort a list according to the ordering func will return.
list | The list handle to sort. |
limit | The maximum number of list elements to sort. |
func | A function pointer that can handle comparing the list data nodes. |
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:
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List::data, eina_list_nth_list(), _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by ecore_file_ls(), and eina_rectangle_pool_request().
Eina_List* eina_list_shuffle | ( | Eina_List * | list, |
Eina_Random_Cb | func | ||
) |
Shuffle list.
list | The list handle to shuffle. |
func | A function pointer that can return an int between 2 inclusives values |
This function shuffles list
. func
is used to generate random list indexes within the range of unshuffled list items. If func
is NULL
, rand is used.
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Merge two list.
left | Head list to merge. |
right | Tail list to merge. |
This function puts right at the end of left and returns the head.
Both left and right do not exist anymore after the merge.
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Referenced by evas_textblock_cursor_range_geometry_get().
Eina_List* eina_list_sorted_merge | ( | Eina_List * | left, |
Eina_List * | right, | ||
Eina_Compare_Cb | func | ||
) |
Merge two sorted list according to the ordering func will return.
left | First list to merge. |
right | Second list to merge. |
func | A function pointer that can handle comparing the list data nodes. |
This function compares the head of left
and right
, and choose the smallest one to be head of the returned list. It will continue this process for all entry of both list.
Both left and right lists are not vailid anymore after the merge and should not be used. If func
is NULL
, it will return NULL
.
Example:
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List::data, _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Split a list into 2 lists.
list | List to split. |
relative | The list will be split after relative . |
right | The head of the new right list. |
This function splits list
into two lists ( left and right ) after the node relative
. Relative
will become the last node of the left list. If list
or right
are NULL
list is returns. If relative
is NULL right is set to list
and NULL
is returns. If relative
is the last node of list
list is returns and right
is set to NULL
.
list does not exist anymore after the split.
list
must be a pointer to the first element of the list. References _Eina_List::accounting, _Eina_List_Accounting::count, eina_list_last(), eina_list_next(), _Eina_List_Accounting::last, _Eina_List::next, and _Eina_List::prev.
Eina_List* eina_list_search_sorted_near_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data, | ||
int * | result_cmp | ||
) |
Returns node nearest to data is in the sorted list.
list | The list to search for data, must be sorted. |
func | A function pointer that can handle comparing the list data nodes. |
data | reference value to search. |
result_cmp | if provided returns the result of func(node->data, data) node being the last (returned) node. If node was found (exact match), then it is 0. If returned node is smaller than 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 found.This function searches for a node containing data
as it's data in list
, if such a node exists it will be returned and result_cmp
will be 0
. If the data of no node in list
is equal to data
, the node with the nearest value to that will be returned and result_cmp
will be the return value of func
with data
and the returned node's data as arguments.
This function is useful for inserting an element in the list only in case it isn't already present in the list, the naive way of doing this would be:
However this has the downside of walking through the list twice, once to check if the data is already present and another to insert the element in the corret position. This can be done more eficiently:
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 before.
list
must be a pointer to the first element of the list.References _Eina_List::accounting, _Eina_List_Accounting::count, _Eina_List::data, _Eina_List_Accounting::last, and _Eina_List::next.
Referenced by eina_list_search_sorted_list(), and eina_list_sorted_insert().
Eina_List* eina_list_search_sorted_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns node if data is in the sorted list.
list | The list to search for data, must be sorted. |
func | A function pointer that can handle comparing the list data nodes. |
data | reference value to search. |
NULL
if not found.This can be used to check if some value is inside the list and get the container node in this case. It should be used when list is known to be sorted as it will do binary search for results.
Example: imagine user gives a string, you check if it's in the list before duplicating its contents.
list
must be a pointer to the first element of the list.References eina_list_search_sorted_near_list().
Referenced by eina_list_search_sorted().
void* eina_list_search_sorted | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns node data if it is in the sorted list.
list | The list to search for data, must be sorted. |
func | A function pointer that can handle comparing the list data nodes. |
data | reference value to search. |
node->data
) if func(node->data, data) == 0, NULL if not found.This can be used to check if some value is inside the list and get the existing instance in this case. It should be used when list is known to be sorted as it will do binary search for results.
Example: imagine user gives a string, you check if it's in the list before duplicating its contents.
list
must be a pointer to the first element of the list.References eina_list_data_get(), and eina_list_search_sorted_list().
Eina_List* eina_list_search_unsorted_list | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns node if data is in the unsorted list.
list | The list to search for data, may be unsorted. |
func | A function pointer that can handle comparing the list data nodes. |
data | reference value to search. |
NULL
if not found.This can be used to check if some value is inside the list and get the container node in this case.
Example: imagine user gives a string, you check if it's in the list before duplicating its contents.
list
must be a pointer to the first element of the list.References EINA_LIST_FOREACH.
Referenced by eina_list_search_unsorted().
void* eina_list_search_unsorted | ( | const Eina_List * | list, |
Eina_Compare_Cb | func, | ||
const void * | data | ||
) |
Returns node data if it is in the unsorted list.
list | The list to search for data, may be unsorted. |
func | A function pointer that can handle comparing the list data nodes. |
data | reference value to search. |
node->data
) if func(node->data, data) == 0, NULL
if not found.This can be used to check if some value is inside the list and get the existing instance in this case.
Example: imagine user gives a string, you check if it's in the list before duplicating its contents.
list
must be a pointer to the first element of the list.References eina_list_data_get(), and eina_list_search_unsorted_list().
Referenced by efreet_desktop_category_add(), efreet_desktop_category_del(), and efreet_menu_desktop_remove().
Get the last list node in the list.
list | The list to get the last list node from. |
This function returns the last list node in the list list
. If list
is NULL
or empty, NULL
is returned.
This is a order-1 operation (it takes the same short time regardless of the length of the list).
list
must be a pointer to the first element of the list. Referenced by eina_list_iterator_reversed_new(), and eina_list_split_list().
Get the next list node after the specified list node.
list | The list node to get the next list node from |
NULL
otherwise.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
.
list
must be a pointer to the first element of the list. Referenced by edje_color_class_del(), edje_color_class_set(), edje_text_class_del(), edje_text_class_set(), eet_eina_stream_data_descriptor_class_set(), and eina_list_split_list().
Get the previous list node before the specified list node.
list | The list node to get the previous list node from. |
NULL
otherwise. if no previous list node existsThis 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
.
list
must be a pointer to the first element of the list.
|
inlinestatic |
Get the list node data member.
list | The list node to get the data member of. |
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
.
list
must be a pointer to the first element of the list. Referenced by edje_color_class_del(), edje_color_class_set(), edje_edit_program_afters_clear(), edje_edit_program_targets_clear(), edje_edit_state_name_set(), edje_edit_string_list_free(), edje_file_collection_list_free(), edje_text_class_del(), edje_text_class_set(), eet_eina_stream_data_descriptor_class_set(), efreet_mime_type_icon_get(), eina_list_search_sorted(), and eina_list_search_unsorted().
|
inlinestatic |
Set the list node data member.
list | The list node to get the data member of. |
data | The data member to the list node. |
This function set 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
.
list
must be a pointer to the first element of the list.
|
inlinestatic |
Get the count of the number of items in a list.
list | The list whose count to return. |
This function returns how many members list
contains. If the list is NULL
, 0
is returned.
NB: This is an order-1 operation and takes the same time regardless of the length of the list.
list
must be a pointer to the first element of the list. Referenced by ecore_file_ls(), ecore_thread_pending_feedback_get(), ecore_thread_pending_get(), ecore_thread_pending_total_get(), edje_edit_state_name_set(), eet_node_var_array_new(), efreet_desktop_category_count_get(), efreet_desktop_type_add(), efreet_menu_desktop_insert(), and ethumb_client_thumb_exists_cancel().
Eina_Iterator* eina_list_iterator_new | ( | const Eina_List * | list | ) |
Returned a new iterator associated to a list.
list | The list. |
This function returns a newly allocated iterator associated to list
. If list
is NULL
or the count member of list
is less or equal than 0, this function still returns a valid iterator that will always return false on eina_iterator_next(), thus keeping API sane.
If the memory can not be allocated, NULL is returned. Otherwise, a valid iterator is returned.
list
must be a pointer to the first element of the list.References EINA_MAGIC_SET, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, and FUNC_ITERATOR_NEXT.
Eina_Iterator* eina_list_iterator_reversed_new | ( | const Eina_List * | list | ) |
Returned a new reversed iterator associated to a list.
list | The list. |
This function returns a newly allocated iterator associated to list
. If list
is NULL
or the count member of list
is less or equal than 0, this function still returns a valid iterator that will always return false on eina_iterator_next(), thus keeping API sane.
Unlike eina_list_iterator_new(), this will walk the list backwards.
If the memory can not be allocated, NULL is returned. Otherwise, a valid iterator is returned.
list
must be a pointer to the first element of the list.References eina_list_last(), EINA_MAGIC_SET, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, and FUNC_ITERATOR_NEXT.
Eina_Accessor* eina_list_accessor_new | ( | const Eina_List * | list | ) |
Returned a new accessor associated to a list.
list | The list. |
This function returns a newly allocated accessor associated to list
. If list
is NULL
or the count member of list
is less or equal than 0, this function returns NULL
. If the memory can not be allocated, NULL
is returned Otherwise, a valid accessor is returned.
list
must be a pointer to the first element of the list. References EINA_MAGIC_SET, FUNC_ACCESSOR_FREE, FUNC_ACCESSOR_GET_AT, and FUNC_ACCESSOR_GET_CONTAINER.