soma-io 6.0.6
soma::AllocatedVector< T > Class Template Reference

A STL-like vector with a smart and slow allocation system for large data buffers. More...

#include <soma-io/utilities/allocatedvector.h>

Public Types

typedef size_t size_type
 
typedef T * iterator
 
typedef const T * const_iterator
 

Public Member Functions

 AllocatedVector (size_type n, const AllocatorContext &ac)
 
 AllocatedVector (const AllocatedVector &other)
 The copy constructor uses a "standard" AllocatorContext using memory allocation.
 
 AllocatedVector (const AllocatedVector &other, const AllocatorContext &ac)
 This copy constructor variant allows to specify a custom AllocatorContext.
 
 AllocatedVector (size_type n, T *buffer)
 This constructor builds a vector on an already allocated buffer.
 
 ~AllocatedVector ()
 
size_type size () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
T & operator[] (size_type i)
 
const T & operator[] (size_type i) const
 
AllocatedVectoroperator= (const AllocatedVector &)
 The copy operator uses a "standard" AllocatorContext using memory allocation.
 
void copy (const AllocatedVector &, const AllocatorContext &)
 contrarily to operator = (), this copy function may use a different allocator, which may be the copied vector allocator.
 
const AllocatorContextallocatorContext () const
 
void free ()
 
void allocate (size_type n, const AllocatorContext &ac)
 

Detailed Description

template<typename T>
class soma::AllocatedVector< T >

A STL-like vector with a smart and slow allocation system for large data buffers.

AllocatedVector is a fixed-size vector (no push_back(), insert() functions, nor reallocation method) which is suitable for very large data that may need the use of memory mapping and/or partial input/output functionalities. However for small data blocks, this container class is not optimal, because the allocation system is rather slow when repeatedly used many times.

Otherwise, AllocatedVector works like a std::vector, or rather like a block.

The allocation system uses an allocation context (AllocatorContext) to automatically switch to the most suitable type of allocation (or memory mapping). This system is describe in the Allocators system section.

Definition at line 62 of file allocatedvector.h.

Member Typedef Documentation

◆ const_iterator

template<typename T>
typedef const T* soma::AllocatedVector< T >::const_iterator

Definition at line 67 of file allocatedvector.h.

◆ iterator

template<typename T>
typedef T* soma::AllocatedVector< T >::iterator

Definition at line 66 of file allocatedvector.h.

◆ size_type

template<typename T>
typedef size_t soma::AllocatedVector< T >::size_type

Definition at line 65 of file allocatedvector.h.

Constructor & Destructor Documentation

◆ AllocatedVector() [1/4]

template<typename T>
soma::AllocatedVector< T >::AllocatedVector ( size_type n,
const AllocatorContext & ac )
inline

◆ AllocatedVector() [2/4]

template<typename T>
soma::AllocatedVector< T >::AllocatedVector ( const AllocatedVector< T > & other)
inline

The copy constructor uses a "standard" AllocatorContext using memory allocation.

Definition at line 121 of file allocatedvector.h.

References allocate(), AllocatedVector(), soma::AllocatorContext::isAllocated(), soma::AllocatorStrategy::ReadOnlyMap, and size().

◆ AllocatedVector() [3/4]

template<typename T>
soma::AllocatedVector< T >::AllocatedVector ( const AllocatedVector< T > & other,
const AllocatorContext & ac )
inline

This copy constructor variant allows to specify a custom AllocatorContext.

Definition at line 137 of file allocatedvector.h.

References allocate(), AllocatedVector(), soma::AllocatorContext::isAllocated(), soma::AllocatorStrategy::ReadOnlyMap, and size().

◆ AllocatedVector() [4/4]

template<typename T>
soma::AllocatedVector< T >::AllocatedVector ( size_type n,
T * buffer )
inline

This constructor builds a vector on an already allocated buffer.

The vector is not owner of the underlying data.

Definition at line 154 of file allocatedvector.h.

References allocate(), and AllocatedVector().

◆ ~AllocatedVector()

template<typename T>
soma::AllocatedVector< T >::~AllocatedVector ( )
inline

Definition at line 166 of file allocatedvector.h.

References free(), and ~AllocatedVector().

Referenced by ~AllocatedVector().

Member Function Documentation

◆ allocate()

template<typename T>
void soma::AllocatedVector< T >::allocate ( size_type n,
const AllocatorContext & ac )
inline

◆ allocatorContext()

template<typename T>
const AllocatorContext & soma::AllocatedVector< T >::allocatorContext ( ) const
inline

Definition at line 172 of file allocatedvector.h.

References allocatorContext().

Referenced by allocatorContext().

◆ begin() [1/2]

template<typename T>
AllocatedVector< T >::iterator soma::AllocatedVector< T >::begin ( )
inline

Definition at line 229 of file allocatedvector.h.

References begin().

Referenced by begin(), begin(), and copy().

◆ begin() [2/2]

template<typename T>
AllocatedVector< T >::const_iterator soma::AllocatedVector< T >::begin ( ) const
inline

Definition at line 236 of file allocatedvector.h.

References begin().

◆ copy()

template<typename T>
void soma::AllocatedVector< T >::copy ( const AllocatedVector< T > & other,
const AllocatorContext & ac )
inline

contrarily to operator = (), this copy function may use a different allocator, which may be the copied vector allocator.

Definition at line 210 of file allocatedvector.h.

References allocate(), AllocatedVector(), begin(), copy(), end(), soma::AllocatorContext::isAllocated(), soma::AllocatorStrategy::ReadOnlyMap, and size().

Referenced by copy(), and operator=().

◆ end() [1/2]

template<typename T>
AllocatedVector< T >::iterator soma::AllocatedVector< T >::end ( )
inline

Definition at line 242 of file allocatedvector.h.

References end().

Referenced by copy(), end(), and end().

◆ end() [2/2]

template<typename T>
AllocatedVector< T >::const_iterator soma::AllocatedVector< T >::end ( ) const
inline

Definition at line 248 of file allocatedvector.h.

References end().

◆ free()

template<typename T>
void soma::AllocatedVector< T >::free ( )
inline

Definition at line 188 of file allocatedvector.h.

References free().

Referenced by allocate(), free(), and ~AllocatedVector().

◆ operator=()

template<typename T>
AllocatedVector< T > & soma::AllocatedVector< T >::operator= ( const AllocatedVector< T > & other)
inline

The copy operator uses a "standard" AllocatorContext using memory allocation.

Definition at line 203 of file allocatedvector.h.

References AllocatedVector(), and copy().

◆ operator[]() [1/2]

template<typename T>
T & soma::AllocatedVector< T >::operator[] ( size_type i)
inline

Definition at line 254 of file allocatedvector.h.

References AllocatedVector().

◆ operator[]() [2/2]

template<typename T>
const T & soma::AllocatedVector< T >::operator[] ( size_type i) const
inline

Definition at line 260 of file allocatedvector.h.

References AllocatedVector().

◆ size()

template<typename T>
AllocatedVector< T >::size_type soma::AllocatedVector< T >::size ( ) const
inline

Definition at line 196 of file allocatedvector.h.

References size().

Referenced by AllocatedVector(), AllocatedVector(), copy(), and size().


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