Ocean
|
This class implements a vector with shifted elements. More...
Public Types | |
typedef T | Type |
Definition of the data type of each element of this object. More... | |
typedef std::ptrdiff_t | Index |
Definition of an element index. More... | |
typedef std::deque< T >::iterator | Iterator |
Definition of a data iterator. More... | |
typedef std::deque< T >::const_iterator | ConstIterator |
Definition of a const data iterator. More... | |
Public Member Functions | |
ShiftVector ()=default | |
Creates a new shift vector object. More... | |
ShiftVector (const ShiftVector< T > &object) | |
Copy constructor. More... | |
ShiftVector (ShiftVector< T > &&object) noexcept | |
Move constructor. More... | |
ShiftVector (const Index firstIndex) | |
Creates a new shift vector object. More... | |
ShiftVector (const Index firstIndex, const size_t size) | |
Creates a new shift vector object. More... | |
ShiftVector (const Index firstIndex, const size_t size, const T &element) | |
Creates a new shift vector object. More... | |
ShiftVector (const Index firstIndex, const T *elements, const size_t size) | |
Creates a new shift vector object and copies a specified number of elements. More... | |
Index | firstIndex () const |
Returns the index of the first element of this object. More... | |
Index | lastIndex () const |
Returns the index of the last (including) element of this object. More... | |
Index | endIndex () const |
Returns the index of the element behind the last (excluding) element of this object. More... | |
void | setFirstIndex (const Index index) |
Sets the index of the first element of this vector. More... | |
const T & | front () const |
Returns the element located at the first index. More... | |
T & | front () |
Returns the element located at the first index. More... | |
const T & | back () const |
Returns the element located at the last (including) index. More... | |
T & | back () |
Returns the element located at the last (including) index. More... | |
size_t | size () const |
Returns the number of elements that are stored by this object. More... | |
void | resize (const size_t size) |
Changes the number of elements of this vector. More... | |
void | resize (const size_t size, const T &element) |
Changes the number of elements of this vector. More... | |
void | pushBack (const T &element) |
Adds a new element to the end of this vector. More... | |
void | pushBack (T &&element) |
Adds a new element to the end of this vector. More... | |
void | pushFront (const T &element) |
Adds a new element to the front of this vector. More... | |
void | pushFront (T &&element) |
Adds a new element to the front of this vector. More... | |
void | popBack () |
Removes an element from the end of this vector. More... | |
void | popFront () |
Removes an element form the front of this vector. More... | |
void | insert (const Index index, const T &element) |
Inserts (or overwrites) an element at a specific position of this vector. More... | |
void | insert (const Index index, const T &element, const T &intermediateElement) |
Inserts (or overwrites) an element at a specific position of this vector. More... | |
void | insert (const Index index, T &&element) |
Inserts (or overwrites) an element at a specific position of this vector. More... | |
void | insert (const Index index, T &&element, const T &intermediateElement) |
Inserts (or overwrites) an element at a specific position of this vector. More... | |
bool | isValidIndex (const Index index) const |
Returns whether a specific index is valid for this vector and matches to the current offset layout. More... | |
bool | isEmpty () const |
Returns whether this object holds no element. More... | |
void | clear () |
Clears this object, the specified index shift will be untouched. More... | |
std::vector< T > | data () const |
Returns a vector storing the elements. More... | |
Iterator | begin () |
Returns the iterator for the first data element. More... | |
ConstIterator | begin () const |
Returns the iterator for the first data element. More... | |
Iterator | end () |
Returns the end iterator. More... | |
ConstIterator | end () const |
Returns the end iterator. More... | |
ShiftVector< T > & | operator= (const ShiftVector< T > &object) |
Assign operator. More... | |
ShiftVector< T > & | operator= (ShiftVector< T > &&object) noexcept |
Move operator. More... | |
const T & | operator[] (const Index index) const |
Returns one element of this object. More... | |
T & | operator[] (const Index index) |
Returns one element of this object. More... | |
operator bool () const | |
Returns whether this object holds at least one element. More... | |
bool | operator== (const ShiftVector< T > &object) const |
Compares two shift vector objects whether they are equal. More... | |
bool | operator!= (const ShiftVector< T > &object) const |
Compares two shift vector object whether they are not equal. More... | |
Protected Attributes | |
Index | firstIndex_ = Index(0) |
The index of the first element. More... | |
std::deque< T > | elements_ |
Elements of this object. More... | |
This class implements a vector with shifted elements.
The elements are shifted by a shift offset index so that the elements can be accessed by adding this shift offset to the normal element index.
The shift offset can either be positive or negative.
T | Data type of the elements that are stored |
typedef std::deque<T>::const_iterator Ocean::ShiftVector< T >::ConstIterator |
Definition of a const data iterator.
typedef std::ptrdiff_t Ocean::ShiftVector< T >::Index |
Definition of an element index.
typedef std::deque<T>::iterator Ocean::ShiftVector< T >::Iterator |
Definition of a data iterator.
typedef T Ocean::ShiftVector< T >::Type |
Definition of the data type of each element of this object.
|
default |
Creates a new shift vector object.
Ocean::ShiftVector< T >::ShiftVector | ( | const ShiftVector< T > & | object | ) |
Copy constructor.
object | Vector object to be copied |
|
noexcept |
Move constructor.
object | Vector object to be moved |
|
explicit |
Creates a new shift vector object.
firstIndex | The index of the first element of this vector |
Ocean::ShiftVector< T >::ShiftVector | ( | const Index | firstIndex, |
const size_t | size | ||
) |
Creates a new shift vector object.
firstIndex | The index of the first element of this vector |
size | Number of elements to be created |
Ocean::ShiftVector< T >::ShiftVector | ( | const Index | firstIndex, |
const size_t | size, | ||
const T & | element | ||
) |
Creates a new shift vector object.
firstIndex | The index of the first element of this vector |
size | Number of elements to be created |
element | Pattern element that will be copied as often as requested |
Ocean::ShiftVector< T >::ShiftVector | ( | const Index | firstIndex, |
const T * | elements, | ||
const size_t | size | ||
) |
Creates a new shift vector object and copies a specified number of elements.
firstIndex | The index of the first element of this vector |
elements | The elements to be copied |
size | Number of elements to be copied |
|
inline |
Returns the element located at the last (including) index.
Beware: Ensure that this object holds at least one element before accessing the element.
|
inline |
Returns the element located at the last (including) index.
Beware: Ensure that this object holds at least one element before accessing the element.
|
inline |
Returns the iterator for the first data element.
|
inline |
Returns the iterator for the first data element.
|
inline |
Clears this object, the specified index shift will be untouched.
std::vector< T > Ocean::ShiftVector< T >::data |
Returns a vector storing the elements.
|
inline |
Returns the end iterator.
|
inline |
Returns the end iterator.
|
inline |
Returns the index of the element behind the last (excluding) element of this object.
Thus, there does not exist an element with the returning index.
|
inline |
Returns the index of the first element of this object.
|
inline |
Returns the element located at the first index.
Beware: Ensure that this object holds at least one element before accessing the element.
|
inline |
Returns the element located at the first index.
Beware: Ensure that this object holds at least one element before accessing the element.
|
inline |
Inserts (or overwrites) an element at a specific position of this vector.
If the position is outside the current range of the vector (in negative or positive direction) than this vector will be extended accordingly.
Whenever the vector will be extended, all intermediate elements (elements at new indices not equal to the given index) are initialized with the default constructor of the data type of this vector.
Beware: If elements have to be added at the front, than the index of the first element will also be adjusted.
index | The index of the element |
element | The element to be inserted at the given index |
|
inline |
Inserts (or overwrites) an element at a specific position of this vector.
If the position is outside the current range of the vector (in negative or positive direction) than this vector will be extended accordingly.
Whenever the vector will be extended, all intermediate elements (elements at new indices not equal to the given index) are initialized with the given intermediate element instance.
Beware: If elements have to be added at the front, than the index of the first element will also be adjusted.
index | The index of the element |
element | The element to be inserted at the given index |
intermediateElement | The element that is copied to all intermediate elements (elements at new indices not equal to the given index) |
|
inline |
Inserts (or overwrites) an element at a specific position of this vector.
If the position is outside the current range of the vector (in negative or positive direction) than this vector will be extended accordingly.
Whenever the vector will be extended, all intermediate elements (elements at new indices not equal to the given index) are initialized with the default constructor of the data type of this vector.
Beware: If elements have to be added at the front, than the index of the first element will also be adjusted.
index | The index of the element |
element | The element to be inserted at the given index |
|
inline |
Inserts (or overwrites) an element at a specific position of this vector.
If the position is outside the current range of the vector (in negative or positive direction) than this vector will be extended accordingly.
Whenever the vector will be extended, all intermediate elements (elements at new indices not equal to the given index) are initialized with the given intermediate element instance.
Beware: If elements have to be added at the front, than the index of the first element will also be adjusted.
index | The index of the element |
element | The element to be inserted at the given index |
intermediateElement | The element that is copied to all intermediate elements (elements at new indices not equal to the given index) |
|
inline |
Returns whether this object holds no element.
|
inline |
Returns whether a specific index is valid for this vector and matches to the current offset layout.
index | The index to be checked |
|
inline |
Returns the index of the last (including) element of this object.
|
inlineexplicit |
Returns whether this object holds at least one element.
|
inline |
Compares two shift vector object whether they are not equal.
object | Second shift vector object to be compared |
ShiftVector< T > & Ocean::ShiftVector< T >::operator= | ( | const ShiftVector< T > & | object | ) |
Assign operator.
object | Vector object to be copied |
|
noexcept |
Move operator.
object | Vector object to be moved |
bool Ocean::ShiftVector< T >::operator== | ( | const ShiftVector< T > & | object | ) | const |
Compares two shift vector objects whether they are equal.
Two shift vector object are equal if they have the same firstIndex() parameter, if they have the same size and if all elements are equal.
object | Second shift vector object to be compared |
|
inline |
Returns one element of this object.
index | The index of the element to be returned, with range [firstIndex(), lastIndex()] |
|
inline |
Returns one element of this object.
index | The index of the element to be returned, with range [firstIndex(), lastIndex()] |
|
inline |
Removes an element from the end of this vector.
The internal shift offset is untouched.
|
inline |
Removes an element form the front of this vector.
The internal shift offset will be incremented by 1 so that the indices of the remaining elements remain unchanged.
|
inline |
Adds a new element to the end of this vector.
The internal shift offset is untouched.
element | New element to be added |
|
inline |
Adds a new element to the end of this vector.
The internal shift offset is untouched.
element | New element to be added |
|
inline |
Adds a new element to the front of this vector.
The internal shift offset will be decremented by 1 so that the indices of the existing elements remain unchanged.
element | New element to be added |
|
inline |
Adds a new element to the front of this vector.
The internal shift offset will be decremented by 1 so that the indices of the existing elements remain unchanged.
element | New element to be added |
|
inline |
Changes the number of elements of this vector.
If the new size is greater than the current size, than new elements are inserted with default initialization of the data type handled by this vector.
size | New element number |
|
inline |
Changes the number of elements of this vector.
If the new size is greater than the current size, than new elements are inserted and initialized as copies of the given pattern element.
size | New element number |
element | The pattern element that is copied to each new internal element if necessary |
|
inline |
Sets the index of the first element of this vector.
The elements of this vector will be untouched, however the individual elements receive a new index due to the new shift offset.
index | The index of the first element |
|
inline |
Returns the number of elements that are stored by this object.
|
protected |
Elements of this object.
|
protected |
The index of the first element.