Ocean
|
This class implements a static vector that has a fixed capacity. More...
Public Member Functions | |
StaticVector ()=default | |
Creates a new vector object. More... | |
StaticVector (const T &value) | |
Creates a new vector object. More... | |
StaticVector (T &&value) | |
Creates a new vector object. More... | |
StaticVector (const size_t number, const T &value) | |
Creates a new vector object. More... | |
StaticVector (const T *values, const size_t size) | |
Creates a new vector object. More... | |
StaticVector (const std::vector< T > &values) | |
Creates a new vector object. More... | |
StaticVector (std::vector< T > &&values) | |
Creates a new vector object. More... | |
size_t | size () const |
Returns the size of this vector. More... | |
bool | occupied () const |
Returns whether no free space is left. More... | |
void | pushBack (const T &value) |
Adds a new element to this vector. More... | |
void | pushBack (T &&value) |
Adds a new element to this vector. More... | |
bool | securePushBack (const T &value) |
Adds a new element to this vector if this vector has free elements left, otherwise nothing happens. More... | |
bool | securePushBack (T &&value) |
Adds a new element to this vector if this vector has free elements left, otherwise nothing happens. More... | |
template<size_t tCapacity2> | |
void | pushBack (const StaticVector< T, tCapacity2 > &value) |
Adds a new elements to this vector. More... | |
void | pushBack (const std::vector< T > &value) |
Adds a new elements to this vector. More... | |
void | popBack () |
Removes the last element from this vector. More... | |
void | securePopBack () |
Removes the last element from this vector. More... | |
void | weakPopBack () |
Removes the last element from this vector. More... | |
void | secureWeakPopBack () |
Removes the last element from this vector. More... | |
void | erase (const size_t index) |
Erases one element of this vector. More... | |
void | unstableErase (const size_t index) |
Erases one element from this vector. More... | |
void | resize (const size_t size) |
Resizes this vector. More... | |
void | weakResize (const size_t size) |
Resizes this vector. More... | |
void | clear () |
Clears all elements of this vector. More... | |
void | weakClear () |
Clears all elements of this vector by setting the internal index to zero (all stored elements are untouched). More... | |
const T & | front () const |
Returns the first elements of this vector. More... | |
T & | front () |
Returns the first elements of this vector. More... | |
const T & | back () const |
Returns the last elements of this vector. More... | |
T & | back () |
Returns the last elements of this vector. More... | |
bool | empty () const |
Returns whether this vector hold no element. More... | |
const T & | operator[] (const size_t index) const |
Returns one element of this vector. More... | |
T & | operator[] (const size_t index) |
Returns one element of this vector. More... | |
bool | operator== (const StaticVector< T, tCapacity > &second) const |
Returns whether two vectors are identical. More... | |
bool | operator!= (const StaticVector< T, tCapacity > &second) const |
Returns whether two vectors are not identical. More... | |
operator bool () const | |
Returns whether this vector holds at least one element. More... | |
Public Member Functions inherited from Ocean::StaticBuffer< T, tCapacity > | |
StaticBuffer ()=default | |
Creates a new buffer object. More... | |
StaticBuffer (const T &value) | |
Creates a new buffer object. More... | |
StaticBuffer (T &&value) | |
Creates a new buffer object. More... | |
StaticBuffer (const T *buffer) | |
Creates a new buffer object. More... | |
StaticBuffer (const size_t number, const T &value) | |
Creates a new buffer object. More... | |
StaticBuffer (const std::vector< T > &values) | |
Creates a new buffer object. More... | |
StaticBuffer (std::vector< T > &&values) | |
Creates a new buffer object. More... | |
void | clear () |
Clears all elements of this buffer. More... | |
const T & | front () const |
Returns the first elements of this buffer. More... | |
T & | front () |
Returns the first elements of this buffer. More... | |
const T & | back () const |
Returns the last elements of this buffer. More... | |
T & | back () |
Returns the last elements of this buffer. More... | |
const T * | data () const |
Returns the buffer data pointer. More... | |
T * | data () |
Returns the buffer data pointer. More... | |
const T & | operator[] (const size_t index) const |
Returns one element of this buffer. More... | |
T & | operator[] (const size_t index) |
Returns one element of this buffer. More... | |
bool | operator== (const StaticBuffer< T, tCapacity > &second) const |
Returns whether two buffers are identical. More... | |
bool | operator!= (const StaticBuffer< T, tCapacity > &second) const |
Returns whether two buffers are not identical. More... | |
Protected Attributes | |
size_t | size_ = 0 |
The current number of stored elements, with range [0, tCapacity]. More... | |
Protected Attributes inherited from Ocean::StaticBuffer< T, tCapacity > | |
T | elements_ [tCapacity > size_t(0) ? tCapacity :size_t(1)] |
Elements of this buffer (with at least one entry). More... | |
Additional Inherited Members | |
Public Types inherited from Ocean::StaticBuffer< T, tCapacity > | |
typedef T | Type |
Definition of the data type of each individual buffer element. More... | |
Static Public Member Functions inherited from Ocean::StaticBuffer< T, tCapacity > | |
static constexpr size_t | capacity () |
Returns the capacity of this buffer. More... | |
This class implements a static vector that has a fixed capacity.
T | Data type of the elements that will be stored |
tCapacity | Number of elements that can be stored, with range [1, infinity) |
|
default |
Creates a new vector object.
|
inlineexplicit |
Creates a new vector object.
value | The value that will be set as first element |
|
inlineexplicit |
Creates a new vector object.
value | The value that will be set as first element |
|
inline |
Creates a new vector object.
number | The number of elements to be created |
value | The value that will be created in the first 'number' elements of this vector |
|
inline |
Creates a new vector object.
values | The values to be copied into this vector object, can be nullptr if 'size == 0' |
size | The number of values to copy, with range [0, tCapacity] |
|
inlineexplicit |
Creates a new vector object.
This constructor converts a stl vector object to a static vector object.
Only the first tCapacity elements of the given vector are copied.
values | The values that will be used as first elements |
|
inlineexplicit |
Creates a new vector object.
This constructor converts a stl vector object to a static vector object.
Only the first tCapacity elements of the given vector are copied.
values | The values that will be used as first elements |
|
inline |
Returns the last elements of this vector.
|
inline |
Returns the last elements of this vector.
|
inline |
Clears all elements of this vector.
|
inline |
Returns whether this vector hold no element.
|
inline |
Erases one element of this vector.
index | The index of the element that will be removed, with range [0, size()) |
|
inline |
Returns the first elements of this vector.
|
inline |
Returns the first elements of this vector.
|
inline |
Returns whether no free space is left.
|
inlineexplicit |
Returns whether this vector holds at least one element.
|
inline |
Returns whether two vectors are not identical.
second | The second vector object |
|
inline |
Returns whether two vectors are identical.
second | The second vector object |
|
inline |
Returns one element of this vector.
Beware: No range check is done.
index | The index of the element that will be returned, with range [0, size()) |
|
inline |
Returns one element of this vector.
Beware: No range check is done.
index | The index of the element that will be returned, with range [0, size()) |
|
inline |
Removes the last element from this vector.
Beware: No range check is applied. Thus: Check that this vector holds at least one element!
|
inline |
Adds a new elements to this vector.
This function avoids a memory overflow.
value | Values to be added |
tCapacity2 | Capacity of the second vector |
|
inline |
Adds a new elements to this vector.
This function avoids a memory overflow.
value | Values to be added |
|
inline |
Adds a new element to this vector.
Beware: No range check is applied.
value | The value to be added |
|
inline |
Adds a new element to this vector.
Beware: No range check is applied.
value | The value to be added |
|
inline |
Resizes this vector.
size | The size to be applied, with range [0, tCapacity] |
|
inline |
Removes the last element from this vector.
If this vector holds no element, nothing is happen.
|
inline |
Adds a new element to this vector if this vector has free elements left, otherwise nothing happens.
value | The value to be added |
|
inline |
Adds a new element to this vector if this vector has free elements left, otherwise nothing happens.
value | The value to be added |
|
inline |
Removes the last element from this vector.
This function simply decreases the element counter, the last element is untouched.
If this vector holds no element, nothing is happen.
|
inline |
Returns the size of this vector.
|
inline |
Erases one element from this vector.
The free element is replace by the last element in the vector, thus the previous order of the elements inside this vector is lost.
This erase function is faster than the standard erase function.
index | The index of the element that will be removed, with range [0, size()) |
|
inline |
Clears all elements of this vector by setting the internal index to zero (all stored elements are untouched).
|
inline |
Removes the last element from this vector.
This function simply decreases the element counter, the last element is untouched.
Beware: No range check is applied. Thus: Check that this vector holds at least one element!
|
inline |
Resizes this vector.
This function simply sets the element counter.
size | The size to be applied, with range [0, tCapacity] |
|
protected |
The current number of stored elements, with range [0, tCapacity].