Vector
Fields
VectorObject * |
|
RED::uint64 |
|
RED::uint64 |
|
Functions
|
|
|
|
|
|
|
|
|
|
|
|
bool |
|
RED::uint64 |
|
RED::uint64 |
|
T & |
|
const T & |
|
T & |
|
const T & |
|
T & |
|
const T & |
|
void |
|
|
|
|
|
void |
|
|
|
|
|
|
|
|
|
void |
|
void |
|
void |
|
void |
|
void |
|
|
Detailed Description
-
template<class T>
class Vector : public RED::Object Vectors of objects or scalars.
@related class RED::Map
Public Functions
-
SET_CID(CID_class_REDVector)
-
IMPLEMENT_AS()
-
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.
-
virtual ~Vector()
RED::Vector destruction method.
-
RED_RC 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
RED_OK when the assignment succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
bool empty() const
- Returns
true if the vector is empty, false if the vector is not empty.
-
T &operator[](RED::uint64 iPos)
Returns a reference to the element at the specified position.
- Parameters
iPos – Requested list access position.
- Returns
A reference to the Object. The returned value is undefined if the provided position is out of the vector boundaries.
-
T &front()
Returns a reference on the first vector element.
- Returns
The first vector Object reference. If the vector is empty, the return value is undefined.
-
T &back()
Returns a reference on the last vector element.
- Returns
The last vector Object reference. If the vector is empty, the return value is undefined.
-
void clear()
Erases the contents of the vector.
All Objects in the vector are destroyed. All vector storage memory is released.
-
RED_RC 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
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC 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
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
void 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.
-
RED_RC 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
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC push_back(const T &iElement)
Adds an object to the end of the vector.
- Parameters
iElement – Element being added.
- Returns
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC push_front(const T &iElement)
Inserts an element at the first position in the vector.
- Parameters
iElement – Element being added.
- Returns
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC 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
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
void pop_back()
Removes the last vector element.
The allocated storage memory is not modified by that call.
-
void pop_front()
Removes the first vector element.
The allocated storage memory is not modified by that call.
-
void 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.
-
void 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.
-
void 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.
-
RED_RC 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
RED_OK if the operation has succeeded,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
SET_CID(CID_class_REDVector)