Ocean
Ocean::NonconstIndexedAccessor< T > Class Template Referenceabstract

This class implements a base class for all indexed-based accessors allowing a non-constant reference access. More...

Inheritance diagram for Ocean::NonconstIndexedAccessor< T >:

Public Member Functions

virtual bool canAccess (const size_t &index) const
 Returns whether this accessor has a specific element. More...
 
virtual bool firstElement (T &element, size_t &index) const
 Returns the first element of this accessor. More...
 
virtual 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...
 
NonconstIndexedAccessor< T > * pointer ()
 Returns the pointer to this object if this accessor holds at least one element (if this accessor is not empty). More...
 
virtual const T & operator[] (const size_t &index) const =0
 Returns one element of this accessor object by a given key. More...
 
virtual T & operator[] (const size_t &index)=0
 Returns one element of this accessor object by a given index. More...
 
- Public Member Functions inherited from Ocean::NonconstAccessor< T, size_t >
virtual T * data ()
 Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps. More...
 
- Public Member Functions inherited from Ocean::ConstAccessor< T, size_t >
virtual const T * data () const
 Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps. More...
 
- Public Member Functions inherited from Ocean::Accessor
virtual ~Accessor ()=default
 Default destructor. More...
 
virtual size_t size () const =0
 Returns the number of accessible elements of this accessor object. More...
 
bool isEmpty () const
 Returns whether this accessor provides no elements. More...
 

Protected Member Functions

 NonconstIndexedAccessor ()=default
 Creates a new accessor object. More...
 
- Protected Member Functions inherited from Ocean::NonconstAccessor< T, size_t >
 NonconstAccessor ()=default
 Creates a new indexed-based accessor object. More...
 
- Protected Member Functions inherited from Ocean::ConstAccessor< T, size_t >
 ConstAccessor ()=default
 Protected default constructor. More...
 
- Protected Member Functions inherited from Ocean::Accessor
 Accessor ()=default
 Protected default constructor. More...
 
 Accessor (const Accessor &accessor)=default
 Protected copy constructor. More...
 
Accessoroperator= (const Accessor &accessor)=delete
 Deleted assign operator. More...
 

Additional Inherited Members

- Public Types inherited from Ocean::ConstAccessor< T, size_t >
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...
 
- Static Public Member Functions inherited from Ocean::Accessor
template<typename TAccessor >
static std::vector< typename TAccessor::Type > accessor2elements (const TAccessor &accessor)
 Returns all elements of a given accessor (as a block). More...
 
template<typename TAccessor >
static std::unordered_map< typename TAccessor::KeyType, typename TAccessor::Type > accessor2map (const TAccessor &accessor)
 Returns all elements of a given accessor as a map with key and elements. More...
 
template<typename TAccessor , typename TIndex >
static std::vector< typename TAccessor::Type > accessor2subsetElements (const TAccessor &accessor, const std::vector< TIndex > &subset)
 Returns a subset of all elements of a given accessor (as a block). More...
 

Detailed Description

template<typename T>
class Ocean::NonconstIndexedAccessor< T >

This class implements a base class for all indexed-based accessors allowing a non-constant reference access.

Template Parameters
TThe data type of the elements of the accessor

Constructor & Destructor Documentation

◆ NonconstIndexedAccessor()

template<typename T >
Ocean::NonconstIndexedAccessor< T >::NonconstIndexedAccessor ( )
protecteddefault

Creates a new accessor object.

Member Function Documentation

◆ canAccess()

template<typename T >
bool Ocean::NonconstIndexedAccessor< T >::canAccess ( const size_t &  index) const
virtual

Returns whether this accessor has a specific element.

See also
ConstAccessor::canAccess().

Implements Ocean::ConstAccessor< T, size_t >.

◆ firstElement()

template<typename T >
bool Ocean::NonconstIndexedAccessor< T >::firstElement ( T &  element,
size_t &  index 
) const
virtual

Returns the first element of this accessor.

See also
ConstAccessor:firstElement().

Implements Ocean::ConstAccessor< T, size_t >.

◆ nextElement()

template<typename T >
bool Ocean::NonconstIndexedAccessor< T >::nextElement ( const size_t &  previousIndex,
T &  nextElement,
size_t &  nextIndex 
) const
virtual

Returns the next element which follows a given key of the previous element.

See also
ConstAccessor::nextElement().

Implements Ocean::ConstAccessor< T, size_t >.

◆ operator[]() [1/2]

template<typename T >
virtual const T& Ocean::NonconstIndexedAccessor< T >::operator[] ( const size_t &  index) const
pure virtual

Returns one element of this accessor object by a given key.

Parameters
indexThe index of element to be accessed, with range [0, size())
Returns
The requested element

Implements Ocean::ConstAccessor< T, size_t >.

Implemented in Ocean::NonconstArrayAccessor< T >.

◆ operator[]() [2/2]

template<typename T >
virtual T& Ocean::NonconstIndexedAccessor< T >::operator[] ( const size_t &  index)
pure virtual

Returns one element of this accessor object by a given index.

Parameters
indexThe index of element to be accessed, with range [0, size())
Returns
The requested element

Implements Ocean::NonconstAccessor< T, size_t >.

Implemented in Ocean::NonconstArrayAccessor< T >.

◆ pointer()

template<typename T >
NonconstIndexedAccessor< T > * Ocean::NonconstIndexedAccessor< T >::pointer
inline

Returns the pointer to this object if this accessor holds at least one element (if this accessor is not empty).

This function can be used to simplify code fragments in which an optional pointer to a non-const accessor is used depending on the factor whether the accessor holds elements or not.

Returns
The accessor's pointer, otherwise nullptr

The documentation for this class was generated from the following file: