Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::Array< T > Class Template Reference

Dynamic array. More...

#include <array.h>

Inheritance diagram for roc::core::Array< T >:
Collaboration diagram for roc::core::Array< T >:

Public Member Functions

 Array (IAllocator &allocator)
 Initialize empty array. More...
 
size_t max_size () const
 Get maximum number of elements. More...
 
size_t size () const
 Get number of elements. More...
 
T & operator[] (size_t index)
 Get element at given position. More...
 
const T & operator[] (size_t index) const
 Get element at given position. More...
 
T & front ()
 Get first element. More...
 
const T & front () const
 Get first element. More...
 
T & back ()
 Get last element. More...
 
const T & back () const
 Get last element. More...
 
void push_back (const T &value)
 Append element to array. More...
 
bool resize (size_t sz)
 Set array size. More...
 
bool grow (size_t max_sz)
 Increase array maximum size. More...
 

Detailed Description

template<class T>
class roc::core::Array< T >

Dynamic array.

Definition at line 25 of file array.h.

Constructor & Destructor Documentation

template<class T>
roc::core::Array< T >::Array ( IAllocator allocator)
inlineexplicit

Initialize empty array.

Definition at line 28 of file array.h.

Member Function Documentation

template<class T>
T& roc::core::Array< T >::back ( )
inline

Get last element.

Precondition
Array should be non-empty.

Definition at line 94 of file array.h.

template<class T>
const T& roc::core::Array< T >::back ( ) const
inline

Get last element.

Precondition
Array should be non-empty.

Definition at line 104 of file array.h.

template<class T>
T& roc::core::Array< T >::front ( )
inline

Get first element.

Precondition
Array should be non-empty.

Definition at line 74 of file array.h.

template<class T>
const T& roc::core::Array< T >::front ( ) const
inline

Get first element.

Precondition
Array should be non-empty.

Definition at line 84 of file array.h.

template<class T>
bool roc::core::Array< T >::grow ( size_t  max_sz)
inline

Increase array maximum size.

Remarks
If max_sz is greater than the current maximum size, a larger memory region is allocated and the array elements are copied there.
Returns
false if the allocation failed

Definition at line 155 of file array.h.

template<class T>
size_t roc::core::Array< T >::max_size ( ) const
inline

Get maximum number of elements.

Definition at line 44 of file array.h.

template<class T>
T& roc::core::Array< T >::operator[] ( size_t  index)
inline

Get element at given position.

Definition at line 54 of file array.h.

template<class T>
const T& roc::core::Array< T >::operator[] ( size_t  index) const
inline

Get element at given position.

Definition at line 63 of file array.h.

template<class T>
void roc::core::Array< T >::push_back ( const T &  value)
inline

Append element to array.

Precondition
Array size() should be less than max_size().

Definition at line 114 of file array.h.

template<class T>
bool roc::core::Array< T >::resize ( size_t  sz)
inline

Set array size.

Remarks
Calls grow() to ensure that there is enough space in array.
Returns
false if the allocation failed

Definition at line 128 of file array.h.

template<class T>
size_t roc::core::Array< T >::size ( ) const
inline

Get number of elements.

Definition at line 49 of file array.h.


The documentation for this class was generated from the following file: