LightsprintSDK 2021.08.08
rr::RRVector< C > Class Template Reference

#include <RRVector.h>

Public Member Functions

 RRVector ()
 
 RRVector (const RRVector &a)
 
RRVectoroperator= (const RRVector &a)
 
void resize (unsigned newSize, C initial=C())
 
void push_back (C a)
 
void pop_back ()
 
void erase (C *e)
 
size_t size () const
 
C & operator[] (unsigned i)
 
const C & operator[] (unsigned i) const
 
void clear ()
 
C * begin ()
 
const C * begin () const
 
C * end ()
 
const C * end () const
 
void insert (C *_where, const C *_first, const C *_last)
 
bool operator== (const RRVector< C > &a) const
 
bool operator!= (const RRVector< C > &a) const
 
 ~RRVector ()
 

Protected Attributes

C * c
 
unsigned numAllocated
 
unsigned numUsed
 

Detailed Description

template<class C>
class rr::RRVector< C >

Portable but limited, minimalistic std::vector replacement.

It works like std::vector in simple cases in Lightsprint SDK interface where C is pointer, RRObject* or RRLight*, and vector size is small (no risk of allocation failure). It is not suitable for anything more complex.

Purpose of RRVector used to be to replace STL in public Lightsprint headers, to make Lightsprint binaries work with any STL implementation. It is also bit smaller than std::vector.

Constructor & Destructor Documentation

◆ RRVector() [1/2]

template<class C >
rr::RRVector< C >::RRVector ( )
inline

Creates empty vector (like std::vector).

◆ RRVector() [2/2]

template<class C >
rr::RRVector< C >::RRVector ( const RRVector< C > &  a)
inline

Creates vector by copying. Uses memcpy to copy elements (unlike std::vector).

!! failure not handled

◆ ~RRVector()

template<class C >
rr::RRVector< C >::~RRVector ( )
inline

Frees elements. Doesn't call element destructors (unlike std::vector).

Member Function Documentation

◆ operator=()

template<class C >
RRVector & rr::RRVector< C >::operator= ( const RRVector< C > &  a)
inline

Assigns vector. Uses memcpy to copy elements (unlike std::vector).

!! failure not handled

◆ resize()

template<class C >
void rr::RRVector< C >::resize ( unsigned  newSize,
initial = C() 
)
inline

Resizes vector, adding or removing elements at the end. Does not destruct removed elements (unlike std::vector).

◆ push_back()

template<class C >
void rr::RRVector< C >::push_back ( a)
inline

Appends element at the end of vector. Elements may be relocated to different address in memory. Does shallow copy at relocation (unlike std::vector).

!! failure not handled

◆ pop_back()

template<class C >
void rr::RRVector< C >::pop_back ( )
inline

Removes last element from vector. Destructor is not called (unlike std::vector).

◆ erase()

template<class C >
void rr::RRVector< C >::erase ( C *  e)
inline

Removes i-th element from vector. Destructor is not called (unlike std::vector).

◆ size()

template<class C >
size_t rr::RRVector< C >::size ( ) const
inline

Returns number of elements in vector (like std::vector).

◆ operator[]() [1/2]

template<class C >
C & rr::RRVector< C >::operator[] ( unsigned  i)
inline

Returns reference to i-th element (like std::vector).

◆ operator[]() [2/2]

template<class C >
const C & rr::RRVector< C >::operator[] ( unsigned  i) const
inline

Returns const reference to i-th element (like std::vector).

◆ clear()

template<class C >
void rr::RRVector< C >::clear ( )
inline

Clear all elements from vector, setting size to 0. Doesn't call element destructors (unlike std::vector).

◆ begin() [1/2]

template<class C >
C * rr::RRVector< C >::begin ( )
inline

Returns iterator pointing to first element (like std::vector).

◆ begin() [2/2]

template<class C >
const C * rr::RRVector< C >::begin ( ) const
inline

◆ end() [1/2]

template<class C >
C * rr::RRVector< C >::end ( )
inline

Returns iterator pointing beyond last element (like std::vector).

◆ end() [2/2]

template<class C >
const C * rr::RRVector< C >::end ( ) const
inline

◆ insert()

template<class C >
void rr::RRVector< C >::insert ( C *  _where,
const C *  _first,
const C *  _last 
)
inline

Inserts range of elements. Destination must be end of current vector (unlike std::vector).

◆ operator==()

template<class C >
bool rr::RRVector< C >::operator== ( const RRVector< C > &  a) const
inline

◆ operator!=()

template<class C >
bool rr::RRVector< C >::operator!= ( const RRVector< C > &  a) const
inline

Member Data Documentation

◆ c

template<class C >
C* rr::RRVector< C >::c
protected

◆ numAllocated

template<class C >
unsigned rr::RRVector< C >::numAllocated
protected

◆ numUsed

template<class C >
unsigned rr::RRVector< C >::numUsed
protected