IndexSupportasmjit::ArenaVector< T >

asmjit::ArenaVector< T > Class Template Reference [¶]

Inheritance diagram for asmjit::ArenaVector< T >:
asmjit::ArenaVectorBase
template<typename T>
class asmjit::ArenaVector< T >

Template used to store and manage array of Arena allocated data.

This template has these advantages over other std::vector<>:

  • Always non-copyable (designed to be non-copyable, we want it).
  • Optimized for working only with POD types.
  • Explicit allocation - Arena is not part of the data for improved memory footprint.

Public Types

Types (C++ compatibility)
Public Types inherited from asmjit::ArenaVectorBase

Member Functions

Construction & Destruction
Overloaded Operators
Accessors
C++ Compatibility (Iterators)
Iteration
Utilities
Utility Functions
Memory Management
Public Member Functions inherited from asmjit::ArenaVectorBase

Additional Inherited Members

Public Attributes inherited from asmjit::ArenaVectorBase
Protected Member Functions inherited from asmjit::ArenaVectorBase

template<typename T>
ArenaVector<T>::ArenaVector()noexcept[1/2][¶]

Creates a default constructed ArenaVector (data pointer is null, and both length/capacity is zero).

template<typename T>
ArenaVector<T>::ArenaVector(
ArenaVector<T>&& other
)noexcept[2/2][¶]

Moves an existing vector into this instance and resets the other instance.

template<typename T>
ArenaVector& ArenaVector<T>::operator=(
ArenaVector<T>&& other
)noexcept[¶]

Implements a move assignment operator. The other instance is reset before this instance is set.

Note

It's recommended to first release the memory of the destination vector as there is no way how to do it after the move, unless it's guaranteed that the destination vector is default constructed.

template<typename T>
T& ArenaVector<T>::operator[](
size_t i
)nodiscardnoexcept[1/2][¶]

Returns item at index i.

template<typename T>
const T& ArenaVector<T>::operator[](
size_t i
) constnodiscardnoexcept[2/2][¶]

Returns item at index i.

template<typename T>
ArenaVector<T>::operator Span<T>() constnodiscardnoexcept[¶]

Returns a non-owning span of this vector.

template<typename T>
Span<T> ArenaVector<T>::as_span() constnodiscardnoexcept[¶]

Returns a non-owning span of this vector.

template<typename T>
T* ArenaVector<T>::data()nodiscardnoexcept[1/2][¶]

Returns vector data (mutable).

template<typename T>
const T* ArenaVector<T>::data() constnodiscardnoexcept[2/2][¶]

Returns vector data (const)

template<typename T>
const T* ArenaVector<T>::cdata() constnodiscardnoexcept[¶]

Returns vector data (const)

template<typename T>
const T& ArenaVector<T>::at(
size_t i
) constnodiscardnoexcept[¶]

Returns item at the given index i (const).

template<typename T>
T& ArenaVector<T>::first()nodiscardnoexcept[1/2][¶]

Returns a reference to the first element of the vector.

Note

The vector must have at least one element. Attempting to use first() on empty vector will trigger an assertion failure in debug builds.

template<typename T>
const T& ArenaVector<T>::first() constnodiscardnoexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T>
T& ArenaVector<T>::last()nodiscardnoexcept[1/2][¶]

Returns a reference to the last element of the vector.

Note

The vector must have at least one element. Attempting to use last() on empty vector will trigger an assertion failure in debug builds.

template<typename T>
const T& ArenaVector<T>::last() constnodiscardnoexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T>
void ArenaVector<T>::swap(
ArenaVector<T>& other
)noexcept[¶]

Swaps this vector with other.

template<typename T>
Error ArenaVector<T>::prepend(
Arena& arena,
const T& item
)noexcept[¶]

Prepends item to the vector.

template<typename T>
Error ArenaVector<T>::insert(
Arena& arena,
size_t index,
const T& item
)noexcept[¶]

Inserts an item at the specified index.

template<typename T>
Error ArenaVector<T>::append(
Arena& arena,
const T& item
)noexcept[¶]

Appends item to the vector.

template<typename T>
Error ArenaVector<T>::concat(
Arena& arena,
const ArenaVector<T>& other
)noexcept[¶]

Appends other vector at the end of this vector.

template<typename T>
void ArenaVector<T>::prepend_unchecked(
const T& item
)noexcept[¶]

Prepends item to the vector (unsafe case).

Can only be used together with reserve_additional(). If reserve_additional(N) returns Error::kOk then N elements can be added to the vector without checking if there is a place for them. Used mostly internally.

template<typename T>
void ArenaVector<T>::append_unchecked(
const T& item
)noexcept[¶]

Append sitem to the vector (unsafe case).

Can only be used together with reserve_additional(). If reserve_additional(N) returns Error::kOk then N elements can be added to the vector without checking if there is a place for them. Used mostly internally.

template<typename T>
void ArenaVector<T>::insert_unchecked(
size_t index,
const T& item
)noexcept[¶]

Inserts an item at the specified index (unsafe case).

template<typename T>
void ArenaVector<T>::concat_unchecked(
const ArenaVector<T>& other
)noexcept[¶]

Concatenates all items of other at the end of the vector.

template<typename T>
void ArenaVector<T>::remove_at(
size_t i
)noexcept[¶]

Removes item at index i.

template<typename T>
T ArenaVector<T>::pop()nodiscardnoexcept[¶]

Pops the last element from the vector and returns it.

template<typename T>
template<typename Value>
bool ArenaVector<T>::contains(
Value&& value
) constnoexcept[¶]

Tests whether the vector contains value.

template<typename T>
template<typename Value>
size_t ArenaVector<T>::index_of(
Value&& value
) constnoexcept[¶]

Returns the first index of the given value or Globals::kNPos if it wasn't found.

template<typename T>
template<typename Value>
size_t ArenaVector<T>::last_index_of(
Value&& value
) constnoexcept[¶]

Returns the last index of the given value or Globals::kNPos if it wasn't found.

template<typename T>
void ArenaVector<T>::release(
Arena& arena
)noexcept[¶]

Releases the memory held by ArenaVector<T> back to the arena.

template<typename T>
Error ArenaVector<T>::reserve_fit(
Arena& arena,
size_t n
)nodiscardnoexcept[¶]

Reallocates the underlying array to fit at least n items with fit semantics.

Remarks

This function uses a fit policy, which means that when possible the underlying array would be allocated to hold at least n elements exactly or the resulting capacity would be slightly higher.

template<typename T>
Error ArenaVector<T>::reserve_grow(
Arena& arena,
size_t n
)nodiscardnoexcept[¶]

Reallocates the underlying array to fit at least n items with grow semantics.

If the vector is smaller than n the same growing calculations will be used as if n items were appended to an empty vector, which means reserving additional space for more append operations that could follow.

template<typename T>
Error ArenaVector<T>::reserve_additional(
Arena& arena
)nodiscardnoexcept[1/2][¶]

Called to grow the buffer to fit at least 1 element more.

template<typename T>
Error ArenaVector<T>::reserve_additional(
Arena& arena,
size_t n
)nodiscardnoexcept[2/2][¶]

Called to grow the buffer to fit at least n elements more.

template<typename T>
Error ArenaVector<T>::resize_fit(
Arena& arena,
size_t n
)nodiscardnoexcept[¶]

Resizes the vector to hold n elements with fit semantics.

If n is greater than the current size then the additional elements' content will be initialized to zero. If n is less than the current size then the vector will be truncated to exactly n elements.

template<typename T>
Error ArenaVector<T>::resize_grow(
Arena& arena,
size_t n
)nodiscardnoexcept[¶]

Resizes the vector to hold n elements.

If n is greater than the current size then the additional elements' content will be initialized to zero. If n is less than the current size then the vector will be truncated to exactly n elements.