|
| Array (IArena &arena) |
| Initialize empty array with arena.
|
|
size_t | capacity () const |
| Get maximum number of elements that can be added without reallocation.
|
|
size_t | size () const |
| Get number of elements.
|
|
bool | is_empty () const |
| Check if size is zero.
|
|
T * | data () |
| Get pointer to first element.
|
|
const T * | data () const |
| Get pointer to first element.
|
|
T & | operator[] (size_t index) |
| Get element at given position.
|
|
const T & | operator[] (size_t index) const |
| Get element at given position.
|
|
T & | front () |
| Get reference to first element.
|
|
const T & | front () const |
| Get const reference to first element.
|
|
T & | back () |
| Get reference to last element.
|
|
const T & | back () const |
| Get const reference to last element.
|
|
ROC_ATTR_NODISCARD bool | push_back (const T &value) |
| Append element to array.
|
|
void | pop_back () |
| Remove last element from the array.
|
|
ROC_ATTR_NODISCARD bool | resize (size_t new_size) |
| Set array size.
|
|
void | clear () |
| Set array size to zero.
|
|
ROC_ATTR_NODISCARD bool | grow (size_t min_capacity) |
| Increase array capacity.
|
|
ROC_ATTR_NODISCARD bool | grow_exp (size_t min_capacity) |
| Increase array capacity exponentially.
|
|
template<class T, size_t EmbeddedCapacity = 0>
class roc::core::Array< T, EmbeddedCapacity >
Dynamic array.
Elements are stored continuously in a memory chunk allocated using IArena, or directly in Array object when number of elements is small.
Array supports resizing and inserting and removing elements in the end with amortized O(1) complexity.
- Template Parameters
-
T | defines array element type. It should have default constructor, copy constructor, and assignment operator. |
EmbeddedCapacity | defines number of elements in the fixed-size chunk embedded directly into Array object; it is used instead of dynamic memory if the array size is small enough. |
Definition at line 40 of file array.h.