Schnek
schnek::SingleArrayLazyAllocation< T, rank > Class Template Reference

Allocate a single array for multidimensional grids in C ordering. More...

#include <single-array-allocation.hpp>

Collaboration diagram for schnek::SingleArrayLazyAllocation< T, rank >:

Classes

struct  SizeInfo
 

Public Types

typedef Array< size_t, rank > IndexType
 The grid index type.
 
typedef Range< size_t, rank > RangeType
 The grid range type.
 

Public Member Functions

 SingleArrayLazyAllocation ()
 Default constructor.
 
 SingleArrayLazyAllocation (const SingleArrayLazyAllocation &)
 Copy constructor.
 
SingleArrayLazyAllocation< T, rank > & operator= (const SingleArrayLazyAllocation< T, rank > &)
 Assignment operator.
 
 ~SingleArrayLazyAllocation ()
 destructor
 

Protected Types

typedef std::function< void()> UpdaterType
 

Protected Member Functions

void resizeImpl (const IndexType &lo, const IndexType &hi)
 resizes to grid with lower indices lo[0],...,lo[rank-1] and upper indices hi[0],...,hi[rank-1]
 
void onUpdate (const UpdaterType &updater)
 Add an updater to the data. More...
 

Protected Attributes

std::shared_ptr< internal::SingleArrayAllocationData< T, SizeInfo > > data
 The pointer to the data.
 
size_t size
 The length of the array.
 
RangeType range
 The lowest and highest coordinates in the grid (inclusive)
 
IndexType dims
 The dimensions of the grid dims = high - low + 1
 

Detailed Description

template<typename T, size_t rank>
class schnek::SingleArrayLazyAllocation< T, rank >

Allocate a single array for multidimensional grids in C ordering.

Deallocation and allocation is performed only when required. When the memory need grows, the storage will allocate slightly more memory that needed. Shrinking of the allocated space happens lazily.

Use this, when a resize is expected regularly.

Template Parameters
TThe type of data stored in the grid
rankThe rank of the grid

Member Function Documentation

◆ onUpdate()

template<typename T , size_t rank>
void schnek::SingleArrayLazyAllocation< T, rank >::onUpdate ( const UpdaterType &  updater)
protected

Add an updater to the data.

The updater is called when the data is resized.


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