Templatious
 All Classes Functions Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
templatious::StaticVector< T > Struct Template Reference

#include <StaticVector.hpp>

Classes

struct  SvIterator
 

Public Types

typedef long ulong
 
typedef StaticVector< T > ThisVector
 
typedef std::remove_const< T >
::type 
ValTrue
 
typedef SvIterator< is_const > Iterator
 
typedef SvIterator< true > ConstIter
 

Public Member Functions

 StaticVector (ValTrue *vct, ulong size)
 
template<class Type = T>
 StaticVector (ValTrue *vct, ulong size, ulong currCnt)
 
 StaticVector (const ThisVector &other)=delete
 
 StaticVector (ThisVector &&other)
 
template<class V >
void push (V &&e)
 
template<class V >
void pushFirst (V &&e)
 
template<class V >
void insert (ulong at, V &&e)
 
template<class V >
void insert (Iterator at, V &&e)
 
bool pop (T &out)
 
pop ()
 
popFirst ()
 
bool popFirst (T &out)
 
Iterator iterAt (ulong pos) const
 
ConstIter citerAt (ulong pos) const
 
void erase (const Iterator &beg, const Iterator &end)
 
void erase (const Iterator &i)
 
T & at (ulong pos) const
 
T & operator[] (ulong i) const
 
bool isFull () const
 
bool isMoved () const
 
bool isEmpty () const
 
ulong size () const
 
Iterator begin () const
 
Iterator end () const
 
ConstIter cbegin () const
 
ConstIter cend () const
 
ValTrue * rawBegin ()
 
ValTrue * rawEnd ()
 
const ValTrue * rawCBegin () const
 
const ValTrue * rawCEnd () const
 
void clear ()
 
T & top ()
 
const T & top () const
 
void popState ()
 
template<class... Args>
void emplaceBack (Args &&...args)
 

Static Public Attributes

static const bool is_const = std::is_const<T>::value
 

Detailed Description

template<class T>
struct templatious::StaticVector< T >

StaticVector is a class whose main purpose is to be like std::vector, but rather use static memory without dynamic allocation.

Although, this class was intended to be used with stack memory, it may be used with any memory given a pointer, element type and size.

To create instances of this collection see templatious::StaticBuffer.

Static vector doesn't take ownership of it's memory, nor is responsible for freeing it. Static vector only destroys objects that reside in the initialized memory which were constructed by this vector. After this vector is destroyed, it's consumed memory is free for reuse.

Parameters
[in]Ttype of objects to hold.

Constructor & Destructor Documentation

template<class T>
templatious::StaticVector< T >::StaticVector ( ValTrue *  vct,
ulong  size 
)
inline

Constructor for static vector which takes in pointer and capacity of this vector.

Parameters
[in]vctMemory to use for this vector.
[in]sizeCapacity of this vector.
template<class T>
template<class Type = T>
templatious::StaticVector< T >::StaticVector ( ValTrue *  vct,
ulong  size,
ulong  currCnt 
)
inline

Constructor which constructs amount of elements specified in currCnt variable. Default constructor with no parameters is used.

Parameters
[in]vctMemory to use for this vector.
[in]sizeCapacity of the vector.
[in]currCntCurrent count of elements. Elements are instantiated with default constructor.
template<class T>
templatious::StaticVector< T >::StaticVector ( ThisVector &&  other)
inline

Move constructor. Takes over memory from the other StaticVector.

Parameters
[in]otherStatic vector to take over memory from.

Member Function Documentation

template<class T>
T& templatious::StaticVector< T >::at ( ulong  pos) const
inline

Get reference to element at pos. Throws if out of bounds.

Parameters
[in]posPosition to get.
template<class T>
Iterator templatious::StaticVector< T >::begin ( ) const
inline

Returns beginning iterator of the vector.

template<class T>
ConstIter templatious::StaticVector< T >::cbegin ( ) const
inline

Returns constant beginning iterator of the vector.

template<class T>
ConstIter templatious::StaticVector< T >::cend ( ) const
inline

Returns constant end iterator of the vector.

template<class T>
ConstIter templatious::StaticVector< T >::citerAt ( ulong  pos) const
inline

Return constant iterator at position pos of this vector.

Parameters
[in]posPosition of iterator.
template<class T>
void templatious::StaticVector< T >::clear ( )
inline

Clear elements from the vector calling destructors on them and resetting size to 0.

template<class T>
template<class... Args>
void templatious::StaticVector< T >::emplaceBack ( Args &&...  args)
inline

Emplace-construct element at the end of the vector. Throws if vector is full.

Parameters
[in]argsArguments to use for construction.
template<class T>
Iterator templatious::StaticVector< T >::end ( ) const
inline

Returns end iterator of the vector.

template<class T>
void templatious::StaticVector< T >::erase ( const Iterator beg,
const Iterator end 
)
inline

Erase elements from this vector from beg to end.

Parameters
[in]begBeginning iterator for erase.
[in]endEnd iterator for erase.
template<class T>
void templatious::StaticVector< T >::erase ( const Iterator i)
inline

Erase single element pointed by iterator i from this vector.

Parameters
[in]iIterator pointing to element for erase.
template<class T>
template<class V >
void templatious::StaticVector< T >::insert ( ulong  at,
V &&  e 
)
inline

Insert element at the position of the vector. Throws if vector is full or moved.

Parameters
[in]atPosition to push at.
[in]eElement to push. Can be const T& or T&&.
template<class T>
template<class V >
void templatious::StaticVector< T >::insert ( Iterator  at,
V &&  e 
)
inline

Insert element at the iterator of the vector. Throws if vector is full or moved.

Parameters
[in]atIterator to push at.
[in]eElement to push. Can be const T& or T&&.
template<class T>
bool templatious::StaticVector< T >::isEmpty ( ) const
inline

Returns if vector is empty.

template<class T>
bool templatious::StaticVector< T >::isFull ( ) const
inline

Returns if vector is full.

template<class T>
bool templatious::StaticVector< T >::isMoved ( ) const
inline

Returns if vector was moved.

template<class T>
Iterator templatious::StaticVector< T >::iterAt ( ulong  pos) const
inline

Return iterator at position pos of this vector.

Parameters
[in]posPosition of iterator.
template<class T>
bool templatious::StaticVector< T >::pop ( T &  out)
inline

Pop element out of the vector into out variable.

Parameters
[out]outVariable to pop into. Returns if true if pop succeeds (vector was not empty), false otherwise.
template<class T>
T templatious::StaticVector< T >::pop ( )
inline

Pop element directly to return value. Throws if vector is empty.

template<class T>
T templatious::StaticVector< T >::popFirst ( )
inline

Pop first element from the vector directly to return value. Throws if vector is empty. Moves subsequent elements back.

template<class T>
bool templatious::StaticVector< T >::popFirst ( T &  out)
inline

Pop first element of the vector to out variable. Returns false if vector is empty. Returns true if pop succeeded.

Parameters
[out]outValue to pop to.
template<class T>
void templatious::StaticVector< T >::popState ( )
inline

Stateful pop of the top element of the vector. Top element is destroyed in the process.

Throws if vector is empty.

template<class T>
template<class V >
void templatious::StaticVector< T >::push ( V &&  e)
inline

Push element to the end of the vector. Throws if vector is full or moved.

Parameters
[in]eElement to push. Can be const T& or T&&.
template<class T>
template<class V >
void templatious::StaticVector< T >::pushFirst ( V &&  e)
inline

Push element to the beginning of the vector. Throws if vector is full or moved.

Parameters
[in]eElement to push. Can be const T& or T&&.
template<class T>
ValTrue* templatious::StaticVector< T >::rawBegin ( )
inline

Returns raw pointer of beginning of the vector.

template<class T>
const ValTrue* templatious::StaticVector< T >::rawCBegin ( ) const
inline

Returns constant raw pointer of beginning of the vector.

template<class T>
const ValTrue* templatious::StaticVector< T >::rawCEnd ( ) const
inline

Returns constant raw pointer of end of the vector (if size is 1) then result is &v[2]

template<class T>
ValTrue* templatious::StaticVector< T >::rawEnd ( )
inline

Returns raw pointer to the end of the vector (if size is 1) then result is &v[2]

template<class T>
ulong templatious::StaticVector< T >::size ( ) const
inline

Returns size of the vector.

template<class T>
T& templatious::StaticVector< T >::top ( )
inline

Get reference to the top element of the vector.

template<class T>
const T& templatious::StaticVector< T >::top ( ) const
inline

Get const reference to the top element of the vector.


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