File view_vector.hpp

Typedefs

template<typename T, typename MemoryAllocator = DefaultMemoryAllocator>
using AllocatedVector = Allocator<Vector<T>, MemoryAllocator>

Allocates the memory, a Vector provides access to.

Template Parameters:
  • T – The type of the values stored in the Vector

  • MemoryAllocator – The type of the memory allocator to be used

template<typename T, typename MemoryAllocator = DefaultMemoryAllocator>
using ResizableVector = ResizableAllocator<Vector<T>, MemoryAllocator>

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

Template Parameters:
  • T – The type of the values stored in the Vector

  • MemoryAllocator – The type of the memory allocator to be used

template<typename T>
class Vector : public View<T>
#include <view_vector.hpp>

A one-dimensional view that provides access to values stored in a pre-allocated array of a specific size.

Template Parameters:

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

Subclassed by Allocator< Vector< T >, MemoryAllocator >, IndexableViewDecorator< Vector >, BinaryDokVectorAllocator< Vector >, IterableIndexedVectorDecorator< Vector >, ListOfLists< T >::Row, ResizableVectorDecorator< Vector >

Public Functions

inline Vector(T *array, uint32 numElements, uint32 padding = 0)
Parameters:
  • array – A pointer to an array of template type T that stores the values, the view should provide access to

  • numElements – The number of elements in the view

  • padding – The number of elements added to the vector to ensure aligned memory access when using SIMD operations

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

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

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

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

inline virtual ~Vector() override
inline View<T>::const_iterator cend() const

Returns a const_iterator to the end of the vector.

Returns:

A const_iterator to the end

inline View<T>::iterator end()

Returns an iterator to the end of the vector.

Returns:

An iterator to the end

inline void clear()

Sets all values stored in the view to zero.

Public Members

uint32 numElements

The number of elements in the view.

uint32 numElementsWithPadding

The number of elements in the view plus the number of elements added to the vector to ensure aligned memory access when using SIMD operations.

struct Hash
#include <view_vector.hpp>

Allows to compute hash values for objects of type Vector.

Public Functions

inline std::size_t operator()(const Vector<T> &v) const

Computes and returns a hash value for a given object of type Vector.

Parameters:

v – A reference to an object of type Vector

Returns:

The hash value

struct Equal
#include <view_vector.hpp>

Allows to check whether two objects of type Vector are equal or not.

Public Functions

inline bool operator()(const Vector<T> &lhs, const Vector<T> &rhs) const

Returns whether two objects of type Vector are equal or not.

Parameters:
  • lhs – A reference to a first object of type Vector

  • rhs – A reference to a second object of type Vector

Returns:

True, if the given objects are equal, false otherwise

template<typename View, typename MemoryAllocator = DefaultMemoryAllocator>
class ResizableAllocator : public Allocator<View, DefaultMemoryAllocator>
#include <view_vector.hpp>

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

Template Parameters:
  • View – The type of the view

  • MemoryAllocator – The type of the memory allocator to be used

Public Functions

inline explicit 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

ResizableAllocator(const ResizableAllocator<View, MemoryAllocator> &other) = delete
Parameters:

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

inline ResizableAllocator(ResizableAllocator<View, MemoryAllocator> &&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 VectorDecorator : public ViewDecorator<View>
#include <view_vector.hpp>

A vector that is backed by a one-dimensional view of a specific size.

Template Parameters:

View – The type of view, the vector is backed by

Public Functions

inline explicit VectorDecorator(View &&view)
Parameters:

view – The view, the vector should be backed by

inline virtual ~VectorDecorator() override
inline uint32 getNumElements() const

Returns the number of elements in the vector.

Returns:

The number of elements in the vector

template<typename Vector>
class IterableVectorDecorator : public IndexableViewDecorator<Vector>
#include <view_vector.hpp>

Provides access via iterators to the values stored in a vector.

Template Parameters:

Vector – The type of the vector

Public Functions

inline explicit IterableVectorDecorator(typename Vector::view_type &&view)
Parameters:

view – The view, the vector should be backed by

inline virtual ~IterableVectorDecorator() override
inline IndexableViewDecorator<Vector>::const_iterator cend() const

Returns a const_iterator to the end of the vector.

Returns:

A const_iterator to the end

inline IndexableViewDecorator<Vector>::iterator end()

Returns an iterator to the end of the vector.

Returns:

An iterator to the end

template<typename Vector>
class ResizableVectorDecorator : public Vector<T>
#include <view_vector.hpp>

Allows to resize a vector.

Template Parameters:

Vector – The type of the vector

Subclassed by ResizableDenseVector< IndexedValue< T >, MemoryAllocator >, ResizableDenseVector< uint32, MemoryAllocator >

Public Functions

inline explicit ResizableVectorDecorator(typename Vector::view_type &&view)
Parameters:

view – The view, the vector should be backed by

inline virtual ~ResizableVectorDecorator() override
inline virtual void setNumElements(uint32 numElements, bool freeMemory)

Sets the number of elements in the vector.

Parameters:
  • numElements – The number of elements to be set

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