Eina_Clist is a compact (inline) list implementation.
More...
|
#define | EINA_CLIST_FOR_EACH(cursor, list) for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next) |
| Iterate through the list. More...
|
|
#define | EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) |
| Iterate through the list, with safety against removal. More...
|
|
#define | EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) |
| Iterate through the list using a list entry. More...
|
|
#define | EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field) |
| Iterate through the list using a list entry, with safety against removal. More...
|
|
#define | EINA_CLIST_FOR_EACH_REV(cursor, list) for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev) |
| Iterate through the list in reverse order. More...
|
|
#define | EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) |
| Iterate through the list in reverse order, with safety against removal. More...
|
|
#define | EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) |
| Iterate through the list in reverse order using a list entry. More...
|
|
#define | EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field) |
| Iterate through the list in reverse order using a list entry, with safety against removal. More...
|
|
#define | EINA_CLIST_INIT(list) { &(list), &(list) } |
| Macros for statically initialized lists. More...
|
|
#define | EINA_CLIST_ENTRY(elem, type, field) ((type *)((char *)(elem) - (uintptr_t)(&((type *)0)->field))) |
| Get pointer to object containing list element. More...
|
|
Eina_Clist is a compact (inline) list implementation.
Elements of this list are members of the structs stored in the list
Advantages over Eina_List and Eina_Inlist :
- uses less memory (two machine words per item)
- allows removing items without knowing which list they're in using O(1) time
- no need to keep updating the head pointer as the list is changed
Disadvantages:
- O(N) time to calculate list length
- requires one list entry in a struct per list (i.e. it's an inlist)
- requires a head/tail pointer
- need to know the list head when moving to next or previous pointer
- Note
- There's no NULL at the end of the list, the last item points to the head.
-
List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init
Define a list like so:
struct gadget
{
struct Eina_Clist entry; <-- doesn
't have to be the first item in the struct int a, b;
};
static Eina_Clist global_gadgets = EINA_CLIST_INIT( global_gadgets );
or
struct some_global_thing
{
};
Manipulate it like this:
And to iterate over it:
struct gadget *gadget;
{
...
}
§ EINA_CLIST_FOR_EACH
#define EINA_CLIST_FOR_EACH |
( |
|
cursor, |
|
|
|
list |
|
) |
| for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next) |
Iterate through the list.
- Parameters
-
cursor | The pointer to be used during the interation. |
list | The list to be interated. |
§ EINA_CLIST_FOR_EACH_SAFE
#define EINA_CLIST_FOR_EACH_SAFE |
( |
|
cursor, |
|
|
|
cursor2, |
|
|
|
list |
|
) |
| |
Value:for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
(cursor) != (list); \
(cursor) = (cursor2), (cursor2) = (cursor)->next)
Iterate through the list, with safety against removal.
- Parameters
-
cursor | The pointer to be used during the interation. |
cursor2 | The auxiliar pointer to be used during the interation. |
list | The list to be interated. |
§ EINA_CLIST_FOR_EACH_ENTRY
#define EINA_CLIST_FOR_EACH_ENTRY |
( |
|
elem, |
|
|
|
list, |
|
|
|
type, |
|
|
|
field |
|
) |
| |
Value: &(elem)->field != (list); \
#define EINA_CLIST_ENTRY(elem, type, field)
Get pointer to object containing list element.
Definition: eina_clist.h:422
Iterate through the list using a list entry.
- Parameters
-
elem | The element to be used. |
list | The list to be iterated. |
type | The type of the list. |
field | The field of the element. |
§ EINA_CLIST_FOR_EACH_ENTRY_SAFE
#define EINA_CLIST_FOR_EACH_ENTRY_SAFE |
( |
|
cursor, |
|
|
|
cursor2, |
|
|
|
list, |
|
|
|
type, |
|
|
|
field |
|
) |
| |
Value: &(cursor)->field != (list); \
(cursor) = (cursor2), \
#define EINA_CLIST_ENTRY(elem, type, field)
Get pointer to object containing list element.
Definition: eina_clist.h:422
Iterate through the list using a list entry, with safety against removal.
- Parameters
-
cursor | The pointer to be used during the interation. |
cursor2 | The auxiliar pointer to be used during the interation. |
list | The list to be interated. |
type | The type of the list. |
field | The field of the element. |
§ EINA_CLIST_FOR_EACH_REV
#define EINA_CLIST_FOR_EACH_REV |
( |
|
cursor, |
|
|
|
list |
|
) |
| for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev) |
Iterate through the list in reverse order.
- Parameters
-
cursor | The pointer to be used during the interation. |
list | The list to be interated. |
§ EINA_CLIST_FOR_EACH_SAFE_REV
#define EINA_CLIST_FOR_EACH_SAFE_REV |
( |
|
cursor, |
|
|
|
cursor2, |
|
|
|
list |
|
) |
| |
Value:for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \
(cursor) != (list); \
(cursor) = (cursor2), (cursor2) = (cursor)->prev)
Iterate through the list in reverse order, with safety against removal.
- Parameters
-
cursor | The pointer to be used during the interation. |
cursor2 | The auxiliar pointer to be used during the interation. |
list | The list to be interated. |
§ EINA_CLIST_FOR_EACH_ENTRY_REV
#define EINA_CLIST_FOR_EACH_ENTRY_REV |
( |
|
elem, |
|
|
|
list, |
|
|
|
type, |
|
|
|
field |
|
) |
| |
Value: &(elem)->field != (list); \
#define EINA_CLIST_ENTRY(elem, type, field)
Get pointer to object containing list element.
Definition: eina_clist.h:422
Iterate through the list in reverse order using a list entry.
- Parameters
-
elem | The element to be used. |
list | The list to be iterated. |
type | The type of the list. |
field | The field of the element. |
§ EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV
#define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV |
( |
|
cursor, |
|
|
|
cursor2, |
|
|
|
list, |
|
|
|
type, |
|
|
|
field |
|
) |
| |
Value: &(cursor)->field != (list); \
(cursor) = (cursor2), \
#define EINA_CLIST_ENTRY(elem, type, field)
Get pointer to object containing list element.
Definition: eina_clist.h:422
Iterate through the list in reverse order using a list entry, with safety against removal.
- Parameters
-
cursor | The pointer to be used during the interation. |
cursor2 | The auxiliar pointer to be used during the interation. |
list | The list to be interated. |
type | The type of the list. |
field | The field of the element. |
§ EINA_CLIST_INIT
#define EINA_CLIST_INIT |
( |
|
list | ) |
{ &(list), &(list) } |
Macros for statically initialized lists.
- Parameters
-
§ EINA_CLIST_ENTRY
#define EINA_CLIST_ENTRY |
( |
|
elem, |
|
|
|
type, |
|
|
|
field |
|
) |
| ((type *)((char *)(elem) - (uintptr_t)(&((type *)0)->field))) |
Get pointer to object containing list element.
- Parameters
-
elem | The element to be used. |
type | The type of the element. |
field | The field of the element. |
Referenced by evas_smart_objects_calculate_count_get().
§ Eina_Clist
This is the list head and the list entry.
- Since
- 1.1.0
§ eina_clist_add_after()
Add an element after the specified one.
- Parameters
-
elem | An element in the list |
to_add | The element to add to the list |
- Precondition
- The list head must be initialized once before adding anything.
-
The element is not in any list.
- Note
- There's no need to initialize an element before adding it to the list.
- Since
- 1.1.0
§ eina_clist_add_before()
Add an element before the specified one.
- Parameters
-
elem | An element in the list |
to_add | The element to add to the list |
- Precondition
- The list head must be initialized once before adding anything.
-
The element is not in any list.
- Note
- There's no need to initialize an element before adding it to the list.
- Since
- 1.1.0
§ eina_clist_add_head()
Add element at the head of the list.
- Parameters
-
list | The list |
elem | An element |
- Precondition
- The list head must be initialized once before adding anything.
-
The element is not in any list.
- Note
- There's no need to initialize an element before adding it to the list.
- Since
- 1.1.0
§ eina_clist_add_tail()
§ eina_clist_element_init()
static void eina_clist_element_init |
( |
Eina_Clist * |
elem | ) |
|
|
inlinestatic |
Init an (unlinked) element.
Call this function on elements that have not been added to the list if you want eina_clist_element_init() to work correctly
- Parameters
-
- Precondition
- The element is not in any list.
- Postcondition
- The element is marked as not being in any list
- Note
- It is not necessary to call this before adding an element to this list.
- Since
- 1.1.0
§ eina_clist_element_is_linked()
static int eina_clist_element_is_linked |
( |
Eina_Clist * |
elem | ) |
|
|
inlinestatic |
§ eina_clist_remove()
static void eina_clist_remove |
( |
Eina_Clist * |
elem | ) |
|
|
inlinestatic |
§ eina_clist_next()
Get the next element.
- Parameters
-
list | The list |
elem | An element |
- Precondition
- elem is in list
- Returns
- The element after elem in list or
NULL
if elem is last in list.
- Since
- 1.1.0
§ eina_clist_prev()
Get the previous element.
- Parameters
-
list | The list |
elem | An element |
- Returns
- The element before elem or
NULL
if elem is the first in the list.
- Since
- 1.1.0
§ eina_clist_head()
§ eina_clist_tail()
Get the last element.
- Parameters
-
- Returns
- The last element in list or
NULL
if list is empty.
- Since
- 1.1.0
§ eina_clist_empty()
static int eina_clist_empty |
( |
const Eina_Clist * |
list | ) |
|
|
inlinestatic |
Check if a list is empty.
- Parameters
-
- Returns
- non-zero if list is empty, zero if it is not
- Since
- 1.1.0
§ eina_clist_init()
Initialize a list.
- Parameters
-
- Precondition
- The list is uninitialized
- Postcondition
- The list contains no items
- Note
- Don't call this function on a list with items
-
This function must be called. Don't try do initialize the list by zero'ing out the list head.
- Since
- 1.1.0
§ eina_clist_count()
static unsigned int eina_clist_count |
( |
const Eina_Clist * |
list | ) |
|
|
inlinestatic |
Count the elements of a list.
- Parameters
-
- Returns
- The number of items in the list
- Since
- 1.1.0
§ eina_clist_move_tail()
Move all elements from src to the tail of dst.
- Parameters
-
dst | List to be appended to |
src | List to append |
- Postcondition
- src is initialized but empty after this operation
- Since
- 1.1.0
§ eina_clist_move_head()
move all elements from src to the head of dst
- Parameters
-
dst | List to be prepended to |
src | List to prepend |
- Postcondition
- src is initialized but empty after this operation
- Since
- 1.1.0