Inline array is a container that stores the data itself, not the pointers to the data. More...
Data Structures | |
struct | _Eina_Inarray |
Inline array structure. More... | |
Macros | |
#define | EINA_INARRAY_FOREACH(array, itr) |
Walks through an array linearly from head to tail. More... | |
#define | EINA_INARRAY_REVERSE_FOREACH(array, itr) |
Walks through an array linearly from tail to head. More... | |
Typedefs | |
typedef struct _Eina_Inarray | Eina_Inarray |
Type for the inlined array. More... | |
Functions | |
Eina_Inarray * | eina_inarray_new (unsigned int member_size, unsigned int step) |
Creates a new inline array. More... | |
void | eina_inarray_free (Eina_Inarray *array) |
Frees an array and its members. More... | |
void | eina_inarray_step_set (Eina_Inarray *array, unsigned int sizeof_eina_inarray, unsigned int member_size, unsigned int step) |
Initializes an inline array. More... | |
void | eina_inarray_flush (Eina_Inarray *array) |
Removes every member from the array. More... | |
int | eina_inarray_push (Eina_Inarray *array, const void *data) |
Copies the data as the last member of the array. More... | |
void * | eina_inarray_grow (Eina_Inarray *array, unsigned int size) |
Allocate new item at the end of the array. More... | |
int | eina_inarray_insert (Eina_Inarray *array, const void *data, Eina_Compare_Cb compare) |
Copies the data to the array at a position found by the comparison function. More... | |
int | eina_inarray_insert_sorted (Eina_Inarray *array, const void *data, Eina_Compare_Cb compare) |
Copies the data to the array at a position found by the comparison function. More... | |
int | eina_inarray_remove (Eina_Inarray *array, const void *data) |
Finds data and removes the matching member. More... | |
void * | eina_inarray_pop (Eina_Inarray *array) |
Removes the last member of the array. More... | |
void * | eina_inarray_nth (const Eina_Inarray *array, unsigned int position) |
Gets the member at the given position. More... | |
Eina_Bool | eina_inarray_insert_at (Eina_Inarray *array, unsigned int position, const void *data) |
Copies the data at the given position in the array. More... | |
void * | eina_inarray_alloc_at (Eina_Inarray *array, unsigned int position, unsigned int member_count) |
Opens a space at the given position, returning its pointer. More... | |
Eina_Bool | eina_inarray_replace_at (Eina_Inarray *array, unsigned int position, const void *data) |
Copies the data to the given position. More... | |
Eina_Bool | eina_inarray_remove_at (Eina_Inarray *array, unsigned int position) |
Removes a member from the given position. More... | |
void | eina_inarray_reverse (Eina_Inarray *array) |
Reverses members in the array. More... | |
void | eina_inarray_sort (Eina_Inarray *array, Eina_Compare_Cb compare) |
Applies a quick sort to the array. More... | |
int | eina_inarray_search (const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare) |
Searches for a member (linear walk). More... | |
int | eina_inarray_search_sorted (const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare) |
Searches for member (binary search walk). More... | |
Eina_Bool | eina_inarray_foreach (const Eina_Inarray *array, Eina_Each_Cb function, const void *user_data) |
Calls function for each array member. More... | |
int | eina_inarray_foreach_remove (Eina_Inarray *array, Eina_Each_Cb match, const void *user_data) |
Removes all the members that match. More... | |
Eina_Bool | eina_inarray_resize (Eina_Inarray *array, unsigned int new_size) |
Resizes array to new size. More... | |
unsigned int | eina_inarray_count (const Eina_Inarray *array) |
Counts the number of members in an array. More... | |
Eina_Iterator * | eina_inarray_iterator_new (const Eina_Inarray *array) |
Returns a new iterator associated to an array. More... | |
Eina_Iterator * | eina_inarray_iterator_reversed_new (const Eina_Inarray *array) |
Returns a new reversed iterator associated to an array. More... | |
Eina_Accessor * | eina_inarray_accessor_new (const Eina_Inarray *array) |
Returns a new accessor associated to an array. More... | |
Inline array is a container that stores the data itself, not the pointers to the data.
This means there is no memory fragmentation, also for small data types(such as char, short, int, and so on) it's more memory efficient.
Usage of the inline array is very similar to that of other Containers, like all arrays adding elements to the beginning of the array is a lot more costly than appending, so those operations should be minimized.
Examples:
#define EINA_INARRAY_FOREACH | ( | array, | |
itr | |||
) |
Walks through an array linearly from head to tail.
[in] | array | The array object |
[in] | itr | An iterator pointer |
itr
must be a pointer with sizeof(itr*) == array->member_size.NULL
pointers or invalid array objects. Use eina_inarray_foreach() to do that.Referenced by edje_object_signal_callback_extra_data_get().
#define EINA_INARRAY_REVERSE_FOREACH | ( | array, | |
itr | |||
) |
Walks through an array linearly from tail to head.
[in] | array | The array object |
[in] | itr | An iterator pointer |
itr
must be a pointer with sizeof(itr*) == array->member_size.NULL
pointers or invalid array objects.Type for the inlined array.
Eina_Inarray* eina_inarray_new | ( | unsigned int | member_size, |
unsigned int | step | ||
) |
Creates a new inline array.
[in] | member_size | The size of each member in the array |
[in] | step | The step size by which to resize the array, do this using the following extra amount |
NULL
on failureThis creates a new array where members are inlined in a sequence. Each member has member_size bytes.
0
, then a safe default is chosen.NULL
is returned. If member_size
is zero, then NULL
is returned.Referenced by efl::eina::_nonpod_inarray< T >::insert().
void eina_inarray_free | ( | Eina_Inarray * | array | ) |
Frees an array and its members.
[in] | array | The array object |
References _Eina_Inarray::members.
Referenced by efl::eina::_inarray_common_base::~_inarray_common_base().
void eina_inarray_step_set | ( | Eina_Inarray * | array, |
unsigned int | sizeof_eina_inarray, | ||
unsigned int | member_size, | ||
unsigned int | step | ||
) |
Initializes an inline array.
[in] | array | The array object to initialize |
[in] | sizeof_eina_inarray | The size of array object |
[in] | member_size | The size of each member in the array |
[in] | step | The step size by which to resize the array, do this using the following extra amount |
This initializes an array. If the step
is 0
, then a safe default is chosen.
void eina_inarray_flush | ( | Eina_Inarray * | array | ) |
Removes every member from the array.
[in] | array | The array object |
References _Eina_Inarray::len, _Eina_Inarray::max, and _Eina_Inarray::members.
Referenced by efl::eina::_pod_inarray< T >::clear(), and efl::eina::_nonpod_inarray< T >::clear().
int eina_inarray_push | ( | Eina_Inarray * | array, |
const void * | data | ||
) |
Copies the data as the last member of the array.
[in] | array | The array object |
[in] | data | The data to be copied at the end |
-1
on errorsThis copies the given pointer contents at the end of the array. The pointer is not referenced, instead its contents are copied to the members array using the previously defined member_size
.
Referenced by efl::eina::_pod_inarray< T >::push_back().
void* eina_inarray_grow | ( | Eina_Inarray * | array, |
unsigned int | size | ||
) |
Allocate new item at the end of the array.
[in] | array | The array object |
[in] | size | The number of new item to allocate |
References _Eina_Inarray::len.
Referenced by evas_async_events_put(), and efl::eina::_pod_inarray< T >::insert().
int eina_inarray_insert | ( | Eina_Inarray * | array, |
const void * | data, | ||
Eina_Compare_Cb | compare | ||
) |
Copies the data to the array at a position found by the comparison function.
[in] | array | The array object |
[in] | data | The data to be copied |
[in] | compare | The compare function |
-1
on errorsThis copies the given pointer contents at the array position defined by the given compare function. The pointer is not referenced, instead its contents are copied to the members array using the previously defined member_size
.
compare
function is a pointer to the member memory itself, do no change it.int eina_inarray_insert_sorted | ( | Eina_Inarray * | array, |
const void * | data, | ||
Eina_Compare_Cb | compare | ||
) |
Copies the data to the array at a position found by the comparison function.
[in] | array | The array object |
[in] | data | The data to be copied |
[in] | compare | The compare function |
-1
on errorsThis copies the given pointer contents at the array position defined by the given compare
function. The pointer is not referenced, instead its contents are copied to the members array using the previously defined member_size
.
compare
function is a pointer to the member memory itself, do no change it.int eina_inarray_remove | ( | Eina_Inarray * | array, |
const void * | data | ||
) |
Finds data and removes the matching member.
[in] | array | The array object |
[in] | data | The data to be found and removed |
-1
on errorsThis finds data in the array and removes it. Data may be an existing member of the array (then optimized) or the contents are matched using memcmp().
void* eina_inarray_pop | ( | Eina_Inarray * | array | ) |
Removes the last member of the array.
[in] | array | The array object |
Referenced by efl::eina::_pod_inarray< T >::pop_back(), and efl::eina::_nonpod_inarray< T >::pop_back().
void* eina_inarray_nth | ( | const Eina_Inarray * | array, |
unsigned int | position | ||
) |
Gets the member at the given position.
[in] | array | The array object |
[in] | position | The member position |
This gets the member given that its position in the array is provided. It is a pointer to its current memory, then it can be invalidated with functions that change the array such as eina_inarray_push(), eina_inarray_insert_at(), or eina_inarray_remove_at(), or variants.
Referenced by efl::eina::_inarray_access_traits::back(), efl::eina::_inarray_access_traits::begin(), efl::eina::_inarray_access_traits::end(), and efl::eina::_inarray_access_traits::front().
Eina_Bool eina_inarray_insert_at | ( | Eina_Inarray * | array, |
unsigned int | position, | ||
const void * | data | ||
) |
Copies the data at the given position in the array.
[in] | array | The array object |
[in] | position | The position to insert the member at |
[in] | data | The data to be copied at the position |
This copies the given pointer contents at the given position
in the array. The pointer is not referenced, instead its contents are copied to the members array using the previously defined member_size
.
References EINA_FALSE.
void* eina_inarray_alloc_at | ( | Eina_Inarray * | array, |
unsigned int | position, | ||
unsigned int | member_count | ||
) |
Opens a space at the given position, returning its pointer.
[in] | array | The array object |
[in] | position | The position to insert first member at (open/allocate space) |
[in] | member_count | The number of times member_size bytes are allocated |
NULL
on errorsReferenced by efl::eina::_pod_inarray< T >::insert().
Eina_Bool eina_inarray_replace_at | ( | Eina_Inarray * | array, |
unsigned int | position, | ||
const void * | data | ||
) |
Copies the data to the given position.
[in] | array | The array object |
[in] | position | The position to copy the member at |
[in] | data | The data to be copied at the position |
This copies the given pointer contents at the given position
in the array. The pointer is not referenced, instead its contents are copied to the members array using the previously defined member_size
.
position
does not exist, it fails.References EINA_FALSE.
Eina_Bool eina_inarray_remove_at | ( | Eina_Inarray * | array, |
unsigned int | position | ||
) |
Removes a member from the given position.
[in] | array | The array object |
[in] | position | The position from which to remove a member |
References EINA_FALSE.
Referenced by efl::eina::_pod_inarray< T >::erase().
void eina_inarray_reverse | ( | Eina_Inarray * | array | ) |
Reverses members in the array.
[in] | array | The array object |
References alloca(), _Eina_Inarray::len, and _Eina_Inarray::member_size.
void eina_inarray_sort | ( | Eina_Inarray * | array, |
Eina_Compare_Cb | compare | ||
) |
Applies a quick sort to the array.
[in] | array | The array object |
[in] | compare | The compare function |
This applies a quick sort to the array.
int eina_inarray_search | ( | const Eina_Inarray * | array, |
const void * | data, | ||
Eina_Compare_Cb | compare | ||
) |
Searches for a member (linear walk).
[in] | array | The array object |
[in] | data | The member to search using the compare function |
[in] | compare | The compare function |
-1
if not foundThis walks through an array by linearly looking for the given data compared by the compare
function.
compare
function is a pointer to the member memory itself, do no change it.int eina_inarray_search_sorted | ( | const Eina_Inarray * | array, |
const void * | data, | ||
Eina_Compare_Cb | compare | ||
) |
Searches for member (binary search walk).
[in] | array | The array object |
[in] | data | The member to search using the compare function |
[in] | compare | The compare function |
-1
if not foundcompare
function.compare
function is a pointer to the member memory itself, do no change it.Eina_Bool eina_inarray_foreach | ( | const Eina_Inarray * | array, |
Eina_Each_Cb | function, | ||
const void * | user_data | ||
) |
Calls function
for each array member.
[in] | array | The array object |
[in] | function | The callback function |
[in] | user_data | The user data given to a callback function |
This calls function
for every given data in array
.
function
should return EINA_TRUE as long as you want the function to continue iterating, by returning EINA_FALSE it stops and returns EINA_FALSE as the result.function
is a pointer to the member memory itself.References EINA_FALSE, and EINA_TRUE.
int eina_inarray_foreach_remove | ( | Eina_Inarray * | array, |
Eina_Each_Cb | match, | ||
const void * | user_data | ||
) |
Removes all the members that match.
[in] | array | The array object |
[in] | match | The match function |
[in] | user_data | The user data given to callback match |
-1
on errorThis removes all the entries in array
, where the match
function returns EINA_TRUE.
Eina_Bool eina_inarray_resize | ( | Eina_Inarray * | array, |
unsigned int | new_size | ||
) |
Resizes array to new size.
[in] | array | The array object |
[in] | new_size | New size for resize |
References EINA_FALSE, EINA_TRUE, and _Eina_Inarray::len.
Referenced by efl::eina::_nonpod_inarray< T >::insert().
unsigned int eina_inarray_count | ( | const Eina_Inarray * | array | ) |
Counts the number of members in an array.
[in] | array | The array object |
References _Eina_Inarray::len.
Referenced by edje_object_signal_callback_extra_data_get(), and efl::eina::_inarray_access_traits::size().
Eina_Iterator* eina_inarray_iterator_new | ( | const Eina_Inarray * | array | ) |
Returns a new iterator associated to an array.
[in] | array | The array object |
This function returns a newly allocated iterator associated to array
.
NULL
is returned. Otherwise, a valid iterator is returned.References EINA_MAGIC_SET, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, FUNC_ITERATOR_NEXT, and _Eina_Inarray::version.
Eina_Iterator* eina_inarray_iterator_reversed_new | ( | const Eina_Inarray * | array | ) |
Returns a new reversed iterator associated to an array.
[in] | array | The array object |
This function returns a newly allocated iterator associated to array
.
NULL
is returned. Otherwise, a valid iterator is returned.References EINA_MAGIC_SET, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, FUNC_ITERATOR_NEXT, and _Eina_Inarray::len.
Eina_Accessor* eina_inarray_accessor_new | ( | const Eina_Inarray * | array | ) |
Returns a new accessor associated to an array.
[in] | array | The array object |
This function returns a newly allocated accessor associated to array
.
NULL
is returned Otherwise, a valid accessor is returned.References EINA_MAGIC_SET, FUNC_ACCESSOR_FREE, FUNC_ACCESSOR_GET_AT, FUNC_ACCESSOR_GET_CONTAINER, and _Eina_Inarray::version.