soma-io  5.1.2
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. More...
 
 AllocatedVector (const AllocatedVector &other, const AllocatorContext &ac)
 This copy constructor variant allows to specify a custom AllocatorContext. More...
 
 AllocatedVector (size_type n, T *buffer)
 This constructor builds a vector on an already allocated buffer. More...
 
 ~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. More...
 
void copy (const AllocatedVector &, const AllocatorContext &)
 contrarily to operator = (), this copy function may use a different allocator, which may be the copied vector allocator. More...
 
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

Definition at line 113 of file allocatedvector.h.

◆ AllocatedVector() [2/4]

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

◆ AllocatedVector() [3/4]

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

◆ 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.

◆ ~AllocatedVector()

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

Definition at line 166 of file allocatedvector.h.

Member Function Documentation

◆ allocate()

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

Definition at line 178 of file allocatedvector.h.

References soma::AllocatorContext::allocate().

◆ allocatorContext()

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

Definition at line 172 of file allocatedvector.h.

◆ begin() [1/2]

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

◆ begin() [2/2]

template<typename T >
AllocatedVector< T >::const_iterator soma::AllocatedVector< T >::begin
inline

Definition at line 236 of file allocatedvector.h.

◆ 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 soma::AllocatedVector< T >::begin(), soma::AllocatorContext::isAllocated(), soma::AllocatorStrategy::ReadOnlyMap, and soma::AllocatedVector< T >::size().

◆ end() [1/2]

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

Definition at line 242 of file allocatedvector.h.

Referenced by soma::AllocatedVector< T >::AllocatedVector().

◆ end() [2/2]

template<typename T >
AllocatedVector< T >::const_iterator soma::AllocatedVector< T >::end
inline

Definition at line 248 of file allocatedvector.h.

◆ free()

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

Definition at line 188 of file allocatedvector.h.

◆ 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.

◆ operator[]() [1/2]

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

Definition at line 254 of file allocatedvector.h.

◆ 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.

◆ size()

template<typename T >
AllocatedVector< T >::size_type soma::AllocatedVector< T >::size
inline

Definition at line 196 of file allocatedvector.h.

Referenced by soma::AllocatedVector< T >::copy().


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