Ocean
|
This class implements an accessor providing direct access to an array of elements. More...
Public Types | |
typedef T | Type |
Definition of the element type of this accessor. More... | |
typedef size_t | KeyType |
Definition of the key (or e.g., index) type of this accessor. More... | |
Public Member Functions | |
NonconstTemplateArrayAccessor ()=default | |
Creates a new empty accessor. More... | |
NonconstTemplateArrayAccessor (NonconstTemplateArrayAccessor< T > &&accessor) noexcept | |
Move constructor. More... | |
NonconstTemplateArrayAccessor (T *elements, const size_t size) | |
Creates a new accessor object. More... | |
NonconstTemplateArrayAccessor (std::vector< T > &elements) | |
Creates a new accessor object. More... | |
NonconstTemplateArrayAccessor (std::vector< T > &elements, const size_t resizeSize) | |
Creates a new accessor object. More... | |
NonconstTemplateArrayAccessor (std::vector< T > *elements, const size_t resizeSize=0) | |
Creates a new accessor object. More... | |
const T * | data () const |
Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps. More... | |
T * | data () |
Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps. More... | |
size_t | size () const |
Returns the number of accessible elements of this accessor object. More... | |
bool | isEmpty () const |
Returns whether this accessor provides no elements. More... | |
bool | canAccess (const size_t &index) const |
Returns whether this accessor has a specific element. More... | |
bool | firstElement (T &element, size_t &index) const |
Returns the first element of this accessor. More... | |
bool | nextElement (const size_t &previousIndex, T &nextElement, size_t &nextIndex) const |
Returns the next element which follows a given key of the previous element. More... | |
const T & | operator[] (const size_t &index) const |
Returns one element of this accessor object. More... | |
T & | operator[] (const size_t &index) |
Returns one element of this accessor object. More... | |
NonconstTemplateArrayAccessor< T > & | operator= (NonconstTemplateArrayAccessor< T > &&accessor) noexcept |
Move operator. More... | |
Protected Attributes | |
T * | elements_ = nullptr |
The elements of this accessor. More... | |
size_t | size_ = 0 |
The number of elements that can be accessed. More... | |
This class implements an accessor providing direct access to an array of elements.
An instance of this accessor does not copy the elements, thus the caller has to ensure that the actual elements exist as long as the instance of the accessor exists.
This class is not derived from Accessor (or any other Accessor class) to avoid virtual functions ensuring higher element-access performances.
Thus, this class will mainly be applied in template functions where the type of the accessor is defined at compile time.
T | The data type of the elements of the accessor |
typedef size_t Ocean::NonconstTemplateArrayAccessor< T >::KeyType |
Definition of the key (or e.g., index) type of this accessor.
typedef T Ocean::NonconstTemplateArrayAccessor< T >::Type |
Definition of the element type of this accessor.
|
default |
Creates a new empty accessor.
|
inlinenoexcept |
Move constructor.
accessor | Accessor to be moved |
|
inline |
Creates a new accessor object.
Beware: The given elements are not copied, they must not be deleted before the accessor is disposed.
elements | The elements that can be accessed, may be nullptr if size is equal 0 |
size | The number of elements that can be accessed, may be 0 if elements is nullptr |
|
inlineexplicit |
Creates a new accessor object.
Beware: The given elements are not copied, they must not be deleted before the accessor is disposed.
elements | A vector holding all elements |
|
inline |
Creates a new accessor object.
This constructor simplifies the creation of an optional NonconstTemplateArrayAccessor object by allowing to provide an empty vector object while defining an explicit resize value.
Beware: The given elements are not copied, they must not be deleted before the accessor is disposed.
elements | A vector holding all elements |
resizeSize | An explicit resize value that will invoke a resizing of the given vector before the vector is connected with the accessor, with range [1, infinity), 0 to avoid any resizing |
|
inlineexplicit |
Creates a new accessor object.
This constructor simplifies the creation of an optional NonconstTemplateArrayAccessor object.
Beware: The given elements are not copied, they must not be deleted before the accessor is disposed.
elements | An optional vector holding all elements, nullptr to create an empty invalid accessor |
resizeSize | An optional possibility to resize the provided elements vector (if defined - otherwise nothing happens), with range [1, infinity), 0 to avoid any resizing |
|
inline |
Returns whether this accessor has a specific element.
|
inline |
Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps.
|
inline |
Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps.
|
inline |
Returns the first element of this accessor.
|
inline |
Returns whether this accessor provides no elements.
|
inline |
Returns the next element which follows a given key of the previous element.
|
inlinenoexcept |
|
inline |
Returns one element of this accessor object.
|
inline |
Returns one element of this accessor object.
|
inline |
Returns the number of accessible elements of this accessor object.
|
protected |
The elements of this accessor.
|
protected |
The number of elements that can be accessed.