lv_array.h
Array. The elements are dynamically allocated by the 'lv_mem' module.
Functions
-
void lv_array_init(lv_array_t *array, uint32_t capacity, uint32_t element_size)
Init an array.
- 参数:
array -- pointer to an
lv_array_t
variable to initializecapacity -- the initial capacity of the array
element_size -- the size of an element in bytes
-
void lv_array_resize(lv_array_t *array, uint32_t new_capacity)
Resize the array to the given capacity.
备注
if the new capacity is smaller than the current size, the array will be truncated.
- 参数:
array -- pointer to an
lv_array_t
variablenew_capacity -- the new capacity of the array
-
void lv_array_deinit(lv_array_t *array)
Deinit the array, and free the allocated memory
- 参数:
array -- pointer to an
lv_array_t
variable to deinitialize
-
uint32_t lv_array_size(const lv_array_t *array)
Return how many elements are stored in the array.
- 参数:
array -- pointer to an
lv_array_t
variable- 返回:
the number of elements stored in the array
-
uint32_t lv_array_capacity(const lv_array_t *array)
Return the capacity of the array, i.e. how many elements can be stored.
- 参数:
array -- pointer to an
lv_array_t
variable- 返回:
the capacity of the array
-
bool lv_array_is_empty(const lv_array_t *array)
Return if the array is empty
- 参数:
array -- pointer to an
lv_array_t
variable- 返回:
true: array is empty; false: array is not empty
-
bool lv_array_is_full(const lv_array_t *array)
Return if the array is full
- 参数:
array -- pointer to an
lv_array_t
variable- 返回:
true: array is full; false: array is not full
-
void lv_array_copy(lv_array_t *target, const lv_array_t *source)
Copy an array to another.
备注
this will create a new array with the same capacity and size as the source array.
- 参数:
target -- pointer to an
lv_array_t
variable to copy tosource -- pointer to an
lv_array_t
variable to copy from
-
void lv_array_clear(lv_array_t *array)
Remove all elements in array.
- 参数:
array -- pointer to an
lv_array_t
variable
-
void lv_array_shrink(lv_array_t *array)
Shrink the memory capacity of array if necessary.
- 参数:
array -- pointer to an
lv_array_t
variable
-
lv_result_t lv_array_remove(lv_array_t *array, uint32_t index)
Remove the element at the specified position in the array.
- 参数:
array -- pointer to an
lv_array_t
variableindex -- the index of the element to remove
- 返回:
LV_RESULT_OK: success, otherwise: error
-
lv_result_t lv_array_erase(lv_array_t *array, uint32_t start, uint32_t end)
Remove from the array either a single element or a range of elements ([start, end)).
备注
This effectively reduces the container size by the number of elements removed.
备注
When start equals to end, the function has no effect.
- 参数:
array -- pointer to an
lv_array_t
variablestart -- the index of the first element to be removed
end -- the index of the first element that is not to be removed
- 返回:
LV_RESULT_OK: success, otherwise: error
-
lv_result_t lv_array_concat(lv_array_t *array, const lv_array_t *other)
Concatenate two arrays. Adds new elements to the end of the array.
备注
The destination array is automatically expanded as necessary.
- 参数:
array -- pointer to an
lv_array_t
variableother -- pointer to the array to concatenate
- 返回:
LV_RESULT_OK: success, otherwise: error
-
lv_result_t lv_array_push_back(lv_array_t *array, const void *element)
Push back element. Adds a new element to the end of the array. If the array capacity is not enough for the new element, the array will be resized automatically.
- 参数:
array -- pointer to an
lv_array_t
variableelement -- pointer to the element to add
- 返回:
LV_RESULT_OK: success, otherwise: error
-
lv_result_t lv_array_assign(lv_array_t *array, uint32_t index, const void *value)
Assigns one content to the array, replacing its current content.
- 参数:
array -- pointer to an
lv_array_t
variableindex -- the index of the element to replace
value -- pointer to the elements to add
- 返回:
true: success; false: error
-
void *lv_array_at(const lv_array_t *array, uint32_t index)
Returns a pointer to the element at position n in the array.
- 参数:
array -- pointer to an
lv_array_t
variableindex -- the index of the element to return
- 返回:
a pointer to the requested element, NULL if
index
is out of range
-
void *lv_array_front(const lv_array_t *array)
Returns a pointer to the first element in the array.
- 参数:
array -- pointer to an
lv_array_t
variable- 返回:
a pointer to the first element in the array
-
void *lv_array_back(const lv_array_t *array)
Returns a pointer to the last element in the array.
- 参数:
array -- pointer to an
lv_array_t
variable
-
struct lv_array_t
- #include <lv_array.h>
Description of a array