File view.hpp

Typedefs

template<typename T>
using AllocatedView = Allocator<View<T>>

Allocates the memory, a View provides access to

Template Parameters:

T – The type of the values stored in the View

template<typename T>
class View
#include <view.hpp>

A view that provides access to values stored in a pre-allocated array.

Template Parameters:

T – The type of the values, the view provides access to

Subclassed by Allocator< View >, ClearableViewDecorator< View >, IndexableViewDecorator< View >, Vector< T >

Public Types

typedef T value_type

The type of the values, the view provides access to.

typedef const value_type *const_iterator

An iterator that provides read-only access to the elements in the view.

typedef value_type *iterator

An iterator that provides access to the elements in the view and allows to modify them.

Public Functions

inline View(T *array, std::initializer_list<uint32> dimensions)
Parameters:
  • array – A pointer to an array of template type T that stores the values, the view should provide access to

  • dimensions – The number of elements in each dimension of the view

inline View(T *array)
Parameters:

array – A pointer to an array of template type T that stores the values, the view should provide access to

inline View(const View<T> &other)
Parameters:

other – A const reference to an object of type View that should be copied

inline View(View<T> &&other)
Parameters:

other – A reference to an object of type View that should be moved

inline virtual ~View()
inline value_type *release()

Releases the ownership of the array that stores the values, the view provides access to. As a result, the behavior of this view becomes undefined and it should not be used anymore. The caller is responsible for freeing the memory that is occupied by the array.

Returns:

A pointer to the array that stores the values, the view provided access to

inline const_iterator cbegin() const

Returns a const_iterator to the beginning of the view.

Returns:

A const_iterator to the beginning

inline iterator begin()

Returns an iterator to the beginning of the view.

Returns:

An iterator to the beginning

inline const value_type &operator[](uint32 pos) const

Returns a const reference to the element at a specific position.

Parameters:

pos – The position of the element

Returns:

A const reference to the specified element

inline value_type &operator[](uint32 pos)

Returns a reference to the element at a specific position.

Parameters:

pos – The position of the element

Returns:

A reference to the specified element

Public Members

T *array

A pointer to the array that stores the values, the view provides access to.

template<typename View>
class Allocator : public View<T>
#include <view.hpp>

Allocates the memory, a view provides access to.

Template Parameters:

View – The type of the view

Subclassed by ResizableAllocator< View >

Public Functions

inline Allocator(uint32 numElements, bool init = false)
Parameters:
  • numElements – The number of elements in the view

  • init – True, if all elements in the view should be value-initialized, false otherwise

inline Allocator(const Allocator<View> &other)
Parameters:

other – A reference to an object of type Allocator that should be copied

inline Allocator(Allocator<View> &&other)
Parameters:

other – A reference to an object of type Allocator that should be moved

inline virtual ~Allocator() override
template<typename View>
class ResizableAllocator : public Allocator<View>
#include <view.hpp>

Allocates the memory, a view provides access to, and allows to resize it afterwards.

Template Parameters:

View – The type of the view

Public Functions

inline ResizableAllocator(uint32 numElements, bool init = false)
Parameters:
  • numElements – The number of elements in the view

  • init – True, if all elements in the view should be value-initialized, false otherwise

inline ResizableAllocator(const ResizableAllocator<View> &other)
Parameters:

other – A reference to an object of type ResizableAllocator that should be copied

inline ResizableAllocator(ResizableAllocator<View> &&other)
Parameters:

other – A reference to an object of type ResizableAllocator that should be moved

inline virtual ~ResizableAllocator() override
inline void resize(uint32 numElements, bool freeMemory)

Resizes the view by re-allocating the memory it provides access to.

Parameters:
  • numElements – The number of elements to which the view should be resized

  • freeMemory – True, if unused memory should be freed, false otherwise

Public Members

uint32 maxCapacity

The maximum number of elements in the view.

template<typename View>
class ViewDecorator
#include <view.hpp>

A base class for all data structures that are backed by a view.

Template Parameters:

View – The type of the view, the data structure is backed by

Subclassed by BinnedVectorDecorator< ViewDecorator< CompositeVector< AllocatedVector< uint32 >, ResizableVector< float64 > > > >, IterableListOfListsDecorator< ViewDecorator< AllocatedListOfLists< Tuple< float64 > > > >, VectorDecorator< AllocatedVector< float64 > >, VectorDecorator< AllocatedVector< uint32 > >, MatrixDecorator< View >, VectorDecorator< View >

Public Types

typedef View view_type

The type of the view, the data structure is backed by.

Public Functions

inline ViewDecorator(View &&view)
Parameters:

view – The view, the data structure should be backed by

inline virtual ~ViewDecorator()
inline const View &getView() const

Returns a const reference to the view, the data structure is backed by.

Returns:

A const reference to an object of template type View, the data structure is backed by

inline View &getView()

Returns a reference to the view, the data structure is backed by.

Returns:

A reference to an object of template type View, the data structure is backed by

Protected Attributes

View view

The view, the data structure is backed by.

template<typename View>
class IndexableViewDecorator : public View<T>
#include <view.hpp>

Provides random access to the values stored in a view.

Template Parameters:

View – The type of the view

Subclassed by Array< T >

Public Types

typedef View::view_type::const_iterator const_iterator

An iterator that provides read-only access to the values stored in the view.

typedef View::view_type::iterator iterator

An iterator that provides access to the values stored in the view and allows to modify them.

Public Functions

inline IndexableViewDecorator(typename View::view_type &&view)
Parameters:

view – The view, the view should be backed by

inline virtual ~IndexableViewDecorator() override
inline const_iterator cbegin() const

Returns a const_iterator to the beginning of the view.

Returns:

A const_iterator to the beginning

inline iterator begin()

Returns an iterator to the beginning of the view.

Returns:

An iterator to the beginning

inline const View::view_type::value_type &operator[](uint32 pos) const

Returns a const reference to the element at a specific position.

Parameters:

pos – The position of the element

Returns:

A const reference to the specified element

inline View::view_type::value_type &operator[](uint32 pos)

Returns a reference to the element at a specific position.

Parameters:

pos – The position of the element

Returns:

A reference to the specified element

template<typename View>
class ClearableViewDecorator : public View<T>
#include <view.hpp>

Allows to set all values stored in a view to zero.

Template Parameters:

View – The type of the view

Public Functions

inline ClearableViewDecorator(typename View::view_type &&view)
Parameters:

view – The view, the view should be backed by

inline virtual ~ClearableViewDecorator() override
inline virtual void clear()

Sets all values stored in the view to zero.