sdk array api documentation

<dmsdk/dlib/array.h>

Templatized array with bounds checking.
template <typename T> class dmArray

The backing storage is either auto-allocated (dynamically allocated) or user-allocated (supplied by user). With exception of changing the size and capacity, all operations are guaranteed to be O(1).

dmArray<int> a;
a.Push(1);

Include: #include <>
FUNCTIONS
void dmArray::Back()

array back

void dmArray::Back()

array back (const)

void dmArray::Begin()

array begin

void dmArray::Capacity()

capacity of array

void dmArray::Empty()

array empty

void dmArray::End()

array end

void dmArray::EraseSwap( index)

array eraseswap

void dmArray::EraseSwapRef( element)

array reference eraseswap

void dmArray::Front()

array front

void dmArray::Front()

array front (const)

void dmArray::Full()

array full

void dmArray::Map( fn,  ctx)

map a function on all values

void dmArray::OffsetCapacity( offset)

array offset capacity

void dmArray::Pop()

array pop

void dmArray::Push( element)

array push

void dmArray::PushArray( array,  count)

array push array

void dmArray::Remaining()

remaining size of array

void dmArray::SetCapacity( capacity)

array set capacity

void dmArray::SetSize( size)

array set size

void dmArray::Size()

size of array

void dmArray::Swap( rhs)

array swap

void dmArray::dmArray()

empty auto-allocated array

void dmArray::dmArray( user_array,  size,  capacity)

user-allocated array

void dmArray::operator[]( index)

array operator[]

void dmArray::operator[]( index)

array operator[] (const)

void dmArray::~dmArray()

array destructor

Functions

dmArray::Back

void dmArray::Back()

Last element of the array

PARAMETERS

RETURNS


dmArray::Back

void dmArray::Back()

Last element of the array (const)

PARAMETERS

RETURNS


dmArray::Begin

void dmArray::Begin()

Pointer to the start of the backing storage

PARAMETERS

RETURNS


dmArray::Capacity

void dmArray::Capacity()

Capacity is currently allocated storage.

PARAMETERS

RETURNS


dmArray::Empty

void dmArray::Empty()

Check if the array is empty. The array is empty when the size is zero.

PARAMETERS

RETURNS


dmArray::End

void dmArray::End()

Pointer to the end of the backing storage The end is essentially outside of the used storage.

PARAMETERS

RETURNS


dmArray::EraseSwap

void dmArray::EraseSwap( index)

Remove the element at the specified index. The removed element is replaced by the element at the end (if any), thus potentially altering the order. While operation changes the array size, it is guaranteed to be O(1).

PARAMETERS

RETURNS


dmArray::EraseSwapRef

void dmArray::EraseSwapRef( element)

Remove the element by reference The removed element is replaced by the element at the end (if any), thus potentially altering the order. While operation changes the array size, it is guaranteed to be O(1).

PARAMETERS

RETURNS


dmArray::Front

void dmArray::Front()

First element of the array

PARAMETERS

RETURNS


dmArray::Front

void dmArray::Front()

First element of the array (const)

PARAMETERS

RETURNS


dmArray::Full

void dmArray::Full()

Check if the array is full. The array is full when the size is equal to the capacity.

PARAMETERS

RETURNS


dmArray::Map

void dmArray::Map( fn,  ctx)

map a function on all values

PARAMETERS


dmArray::OffsetCapacity

void dmArray::OffsetCapacity( offset)

Relative change of capacity Equivalent to SetCapacity(Capacity() + offset). Only allowed for auto-allocated arrays and will result in a new dynamic allocation followed by memcpy of the elements.

PARAMETERS


dmArray::Pop

void dmArray::Pop()

Remove the last element of the array Only allowed when the size is larger than zero.

PARAMETERS


dmArray::Push

void dmArray::Push( element)

Add an element to the end of the array Only allowed when the capacity is larger than size.

PARAMETERS


dmArray::PushArray

void dmArray::PushArray( array,  count)

Add an array of elements to the end of the array Only allowed when the capacity is larger than size + count

PARAMETERS


dmArray::Remaining

void dmArray::Remaining()

Amount of additional elements that can be stored

PARAMETERS

RETURNS


dmArray::SetCapacity

void dmArray::SetCapacity( capacity)

Set the capacity of the array. If the size is less than the capacity, the array is truncated. If it is larger, the array is extended. Only allowed for auto-allocated arrays and will result in a new dynamic allocation followed by memcpy of the elements.

PARAMETERS


dmArray::SetSize

void dmArray::SetSize( size)

Set size of the array

PARAMETERS


dmArray::Size

void dmArray::Size()

Size of the array in elements

PARAMETERS

RETURNS


dmArray::Swap

void dmArray::Swap( rhs)

Swap the content of two arrays

PARAMETERS


dmArray::dmArray

void dmArray::dmArray()

PARAMETERS

EXAMPLES

dmArray<int>* a = new dmArray<int>();

dmArray::dmArray

void dmArray::dmArray( user_array,  size,  capacity)

user-allocated array with initial size and capacity

PARAMETERS


dmArray::operator[]

void dmArray::operator[]( index)

Retrieve an element by index

PARAMETERS

RETURNS


dmArray::operator[]

void dmArray::operator[]( index)

Retrieve an element by index (const)

PARAMETERS

RETURNS


dmArray::~dmArray

void dmArray::~dmArray()

Only frees memory when auto-allocated.

PARAMETERS