![]() |
ROOT-Sim core
3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
|
Dynamic array datatype. More...


Go to the source code of this file.
Macros | |
| #define | INIT_SIZE_ARRAY 8U |
| The initial size of dynamic arrays expressed in the number of elements. | |
| #define | dyn_array(type) |
| Declares a dynamic array. More... | |
| #define | array_items(self) ((self).items) |
| Gets the underlying actual array of elements of a dynamic array. More... | |
| #define | array_count(self) ((self).count) |
| Gets the count of contained element in a dynamic array. More... | |
| #define | array_capacity(self) ((self).capacity) |
| Gets the current capacity of a dynamic array. More... | |
| #define | array_peek(self) (array_items(self)[array_count(self) - 1]) |
| Gets the last element of a dynamic array. More... | |
| #define | array_get_at(self, i) (array_items(self)[(i)]) |
| Gets the i-th element of a dynamic array. More... | |
| #define | array_is_empty(self) (array_count(self) == 0) |
| Check if the dynamic array is empty. More... | |
| #define | array_init(self) |
| Initializes a dynamic array. More... | |
| #define | array_fini(self) __extension__({ mm_free(array_items(self)); }) |
| Releases the memory used by a dynamic array. More... | |
| #define | array_push(self, elem) |
| Push an element to the end of a dynamic array. More... | |
| #define | array_pop(self) |
| Pop an element from the end of a dynamic array. More... | |
| #define | array_add_at(self, i, elem) |
| Insert an element at the given index. More... | |
| #define | array_remove_at(self, i) |
| Remove an element at the given index from the dynamic array. More... | |
| #define | array_truncate_first(self, n) |
| Remove first n elements from the dynamic array. More... | |
| #define | array_shrink(self) |
| Reduce the size of the dynamic array. More... | |
| #define | array_reserve(self, n) |
| Expand the size of the dynamic array to have at least the requested capacity. More... | |
| #define | array_expand(self) |
| Double the size of the dynamic array if the number of elements is greater than the capacity. More... | |
| #define | array_lazy_remove_at(self, i) __extension__({ array_items(self)[(i)] = array_items(self)[--array_count(self)]; }) |
| Remove an element at the given index from the dynamic array, last array element will take its place. More... | |
Typedefs | |
| typedef uint_least32_t | array_count_t |
| The type used to handle dynamic arrays count of elements and capacity. | |
Dynamic array datatype.
Dynamic array datatype
| #define array_add_at | ( | self, | |
| i, | |||
| elem | |||
| ) |
Insert an element at the given index.
| self | The target dynamic array |
| i | The index at which to insert the element |
| elem | The element to insert |
| #define array_capacity | ( | self | ) | ((self).capacity) |
Gets the current capacity of a dynamic array.
| self | The target dynamic array |
| #define array_count | ( | self | ) | ((self).count) |
Gets the count of contained element in a dynamic array.
| self | The target dynamic array |
| #define array_expand | ( | self | ) |
Double the size of the dynamic array if the number of elements is greater than the capacity.
| self | The target dynamic array |
| #define array_fini | ( | self | ) | __extension__({ mm_free(array_items(self)); }) |
Releases the memory used by a dynamic array.
| self | The target dynamic array |
| #define array_get_at | ( | self, | |
| i | |||
| ) | (array_items(self)[(i)]) |
Gets the i-th element of a dynamic array.
| self | The target dynamic array |
| i | The index of the element to get |
| #define array_init | ( | self | ) |
Initializes a dynamic array.
| self | The target dynamic array |
| #define array_is_empty | ( | self | ) | (array_count(self) == 0) |
Check if the dynamic array is empty.
| self | The target dynamic array |
| #define array_items | ( | self | ) | ((self).items) |
Gets the underlying actual array of elements of a dynamic array.
| self | The target dynamic array |
You can use the array to directly index items, but do it at your own risk!
| #define array_lazy_remove_at | ( | self, | |
| i | |||
| ) | __extension__({ array_items(self)[(i)] = array_items(self)[--array_count(self)]; }) |
Remove an element at the given index from the dynamic array, last array element will take its place.
| self | The target dynamic array |
| i | The index of the element to remove |
| #define array_peek | ( | self | ) | (array_items(self)[array_count(self) - 1]) |
Gets the last element of a dynamic array.
| self | the target dynamic array |
You have to check for the array emptiness before safely calling this macro
| #define array_pop | ( | self | ) |
Pop an element from the end of a dynamic array.
| self | The target dynamic array |
| #define array_push | ( | self, | |
| elem | |||
| ) |
Push an element to the end of a dynamic array.
| self | The target dynamic array |
| elem | The element to push |
| #define array_remove_at | ( | self, | |
| i | |||
| ) |
Remove an element at the given index from the dynamic array.
| self | The target dynamic array |
| i | The index of the element to remove |
| #define array_reserve | ( | self, | |
| n | |||
| ) |
Expand the size of the dynamic array to have at least the requested capacity.
| self | The target dynamic array |
| n | The requested capacity |
| #define array_shrink | ( | self | ) |
Reduce the size of the dynamic array.
| self | The target dynamic array |
The size of the dinamic array is halved if the number of elements is less than a third of the capacity.
| #define array_truncate_first | ( | self, | |
| n | |||
| ) |
Remove first n elements from the dynamic array.
| self | The target dynamic array |
| n | The number of elements to remove |
| #define dyn_array | ( | type | ) |
Declares a dynamic array.
| type | The type of the contained elements |