This class implements an accessor providing direct access to a constant array of elements.
More...
|
| ConstArrayAccessor ()=default |
| Creates a new empty accessor.
|
|
| ConstArrayAccessor (ConstArrayAccessor< T > &&accessor) noexcept |
| Move constructor.
|
|
| ConstArrayAccessor (const T *elements, const size_t size) |
| Creates a new accessor object.
|
|
| ConstArrayAccessor (const std::vector< T > &elements) |
| Creates a new accessor object.
|
|
virtual const T * | data () const |
| Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps.
|
|
virtual size_t | size () const |
| Returns the number of accessible elements of this accessor object.
|
|
virtual const T & | operator[] (const size_t &index) const |
| Returns one element of this accessor object.
|
|
ConstArrayAccessor< T > & | operator= (ConstArrayAccessor< T > &&accessor) noexcept |
| Move operator.
|
|
virtual bool | canAccess (const size_t &index) const |
| Returns whether this accessor has a specific element.
|
|
virtual bool | firstElement (T &element, size_t &index) const |
| Returns the first element of this accessor.
|
|
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.
|
|
virtual | ~Accessor ()=default |
| Default destructor.
|
|
bool | isEmpty () const |
| Returns whether this accessor provides no elements.
|
|
|
typedef T | Type |
| Definition of the element type of this accessor.
|
|
typedef size_t | KeyType |
| Definition of the key (or e.g., index) type of this accessor.
|
|
template<typename TAccessor > |
static std::vector< typename TAccessor::Type > | accessor2elements (const TAccessor &accessor) |
| Returns all elements of a given accessor (as a block).
|
|
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.
|
|
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).
|
|
| ConstIndexedAccessor ()=default |
| Creates a new indexed-based accessor object.
|
|
| ConstAccessor ()=default |
| Protected default constructor.
|
|
| Accessor ()=default |
| Protected default constructor.
|
|
| Accessor (const Accessor &accessor)=default |
| Protected copy constructor.
|
|
Accessor & | operator= (const Accessor &accessor)=delete |
| Deleted assign operator.
|
|
template<typename T>
class Ocean::ConstArrayAccessor< T >
This class implements an accessor providing direct access to a constant 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.
The application of the this class is demonstrated in the following code example (compare the code example for ConstTemplateArrayAccessor):
{
for (
size_t n = 0; n < accessor.
size(); ++n)
{
const Object& object = accessor[n];
}
}
void main()
{
std::vector<Object> objects;
iterate(ConstArrayAccessor<Object>(objects));
}
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
- Template Parameters
-
T | The data type of the elements of the accessor |
- See also
- ConstTemplateArrayAccessor, ConstElementAccessor.