template< class T > class RED::Vector
Vectors of objects or scalars.
#include <REDSTL.h>
Inherits: Object.
Public functions:
Vector ( const RED::Vector< T > & iSource ) | |
Vector ( ) | |
virtual | ~Vector ( ) |
virtual void * | As ( const RED::CID & iCID ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
template< class T_As > T_As * | As ( ) |
T & | back ( ) |
const T & | back ( ) const |
RED::uint64 | capacity ( ) const |
void | clear ( ) |
bool | empty ( ) const |
void | erase ( RED::uint64 iPos ) |
void | erase ( RED::uint64 iPosStart, RED::uint64 iPosEnd ) |
T & | front ( ) |
const T & | front ( ) const |
RED_RC | insert ( RED::uint64 iPosition, const T & iElement ) |
RED_RC | operator+= ( const RED::Vector< T > & iVector ) |
RED_RC | operator= ( const RED::Vector< T > & iSource ) |
T & | operator[] ( RED::uint64 iPos ) |
const T & | operator[] ( RED::uint64 iPos ) const |
void | pop_back ( ) |
void | pop_front ( ) |
RED_RC | push_back ( const T & iElement ) |
RED_RC | push_front ( const T & iElement ) |
RED_RC | reserve ( RED::uint64 iNewMemorySize ) |
void | reset ( const T & iDefaultValue ) |
RED_RC | resize ( RED::uint64 iNewSize ) |
RED_RC | resize ( RED::uint64 iNewSize, const T & iDefaultValue ) |
RED::uint64 | size ( ) const |
void | swap ( RED::Vector< T > & ioSecondVector ) |
Public static functions:
static RED::CID | GetClassID ( ) |
Public variables:
RED::uint64 | _mem_size |
VectorObject * | _obj |
RED::uint64 | _size |
Protected functions:
RED_RC | Allocate ( RED::uint64 iMinimalSize = 0 ) |
Functions documentation
public RED::Vector::Vector | ( | const RED::Vector< T > & | iSource | ) |
Vector copy construction method.
If a memory error occurs during the operation, this is set as an empty array, but we can't return any error code from a ctor().
The memory capacity of this is set to the actual size of 'iSource'.
Parameters:
iSource: | Object source defining our contents. |
public RED::Vector::Vector | ( | ) |
Vector default construction method.
public virtual RED::Vector::~Vector | ( | ) |
RED::Vector destruction method.
public static RED::CID RED::Vector::GetClassID | ( | ) |
Reimplements: RED::Object::GetClassID.
public virtual void * RED::Vector::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
public virtual const void * RED::Vector::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public const T_As * RED::Vector::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
template< class T_As > public T_As * RED::Vector::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public T & RED::Vector::back | ( | ) |
Returns a reference on the last vector element.
Returns:
public const T & RED::Vector::back | ( | ) const |
public RED::uint64 RED::Vector::capacity | ( | ) const |
Returns:
public void RED::Vector::clear | ( | ) |
Erases the contents of the vector.
All Objects in the vector are destroyed. All vector storage memory is released.
public bool RED::Vector::empty | ( | ) const |
Returns:
public void RED::Vector::erase | ( | RED::uint64 | iPos | ) |
Removes an element at the specified position.
The allocated storage memory is not modified by that call.
Parameters:
iPos: | Position of the element to be removed. |
public void RED::Vector::erase | ( | RED::uint64 | iPosStart, |
RED::uint64 | iPosEnd | ||
) |
Removes elements between the specified positions.
The allocated storage memory is not modified by that call. erase(i) is equivalent to erase(i,i)
Parameters:
iPosStart: | first position to be removed. |
iPosEnd: | last position to be removed. |
public T & RED::Vector::front | ( | ) |
Returns a reference on the first vector element.
Returns:
public const T & RED::Vector::front | ( | ) const |
public RED_RC RED::Vector::insert | ( | RED::uint64 | iPosition, |
const T & | iElement | ||
) |
Inserts an element at any position in the vector.
Parameters:
iPosition: | Insertion position. Insertion request behind the last position insert as the last element. |
iElement: | Element being added. |
Returns:
public RED_RC RED::Vector::operator+= | ( | const RED::Vector< T > & | iVector | ) |
Addition operator.
Appends the contents of the 'iVector' source vector to the contents of this.
Parameters:
iVector: | Source vector appened at the end of this. |
Returns:
public RED_RC RED::Vector::operator= | ( | const RED::Vector< T > & | iSource | ) |
Assignment operator.
The memory capacity of this is set to the actual size of 'iSource'.
Parameters:
iSource: | Source overwriting our current contents. |
Returns:
public T & RED::Vector::operator[] | ( | RED::uint64 | iPos | ) |
Returns a reference to the element at the specified position.
Parameters:
iPos: | Requested list access position. |
Returns:
public const T & RED::Vector::operator[] | ( | RED::uint64 | iPos | ) const |
public void RED::Vector::pop_back | ( | ) |
Removes the last vector element.
The allocated storage memory is not modified by that call.
public void RED::Vector::pop_front | ( | ) |
Removes the first vector element.
The allocated storage memory is not modified by that call.
public RED_RC RED::Vector::push_back | ( | const T & | iElement | ) |
Adds an object to the end of the vector.
Parameters:
iElement: | Element being added. |
Returns:
public RED_RC RED::Vector::push_front | ( | const T & | iElement | ) |
Inserts an element at the first position in the vector.
Parameters:
iElement: | Element being added. |
Returns:
public RED_RC RED::Vector::reserve | ( | RED::uint64 | iNewMemorySize | ) |
Changes the memory size of the vector.
Simply changes the allocated size of the vector. The vector contents are not modified by the call.
Parameters:
iNewMemorySize: | New number of items to handle in memory. |
Returns:
public void RED::Vector::reset | ( | const T & | iDefaultValue | ) |
Changes all actual vector values to the provided value.
This method changes the values of all vector elements to 'iDefaultValue'. The memory is not modified, the size of the vector is not modified either.
Parameters:
iDefaultValue: | Object default value for added Objects. |
public RED_RC RED::Vector::resize | ( | RED::uint64 | iNewSize | ) |
Changes the size of the vector.
The number of objects in the vector is modified:
- If the actual vector size is below the requested size, new initialized objects are added to the vector until the wished size is reached.
- If the actual vector size is above the requested size, all objects beyond the requested size are deleted. The allocated memory remains.
Parameters:
iNewSize: | New number of objects in the vector. |
Returns:
public RED_RC RED::Vector::resize | ( | RED::uint64 | iNewSize, |
const T & | iDefaultValue | ||
) |
Changes the size of the vector.
Works as Vector::resize, provided an initialization value for all vector objects that may be added.
Parameters:
iNewSize: | New number of objects in the vector. |
iDefaultValue: | Object default value for added Objects. |
Returns:
public RED::uint64 RED::Vector::size | ( | ) const |
Returns:
public void RED::Vector::swap | ( | RED::Vector< T > & | ioSecondVector | ) |
exchange *this and another vector
The allocated storage memory in both vector are just swap. Internal vector variables are swapped too, but each vector keep their own id.
Parameters:
ioSecondVector: | vector to swap with. |
protected RED_RC RED::Vector::Allocate | ( | RED::uint64 | iMinimalSize = 0 | ) |
sAdd memory storage to the vector.
Parameters:
iMinimalSize: | Set to the minimal number of objects to allocate when specified. |
Returns:
Variables documentation
Allocated number of objects in system memory.
Array of Object's.
Number of objects in the array.