CbmRoot
Loading...
Searching...
No Matches
cbm::PartitionedVector< T, Allocator > Class Template Reference

A vector that is partitioned into multiple subvectors. More...

#include <PartitionedVector.h>

Inheritance diagram for cbm::PartitionedVector< T, Allocator >:
[legend]

Public Types

using Container_t = std::vector<T, Allocator>
 

Public Member Functions

 PartitionedVector ()
 Default constructor. Creates an empty vector.
 
 PartitionedVector (Container_t &&data, gsl::span< const size_t > sizes, gsl::span< const uint32_t > addresses)
 Constructor. Creates a vector with n partitions.
 
template<typename OtherAllocator>
 PartitionedVector (const PartitionedVector< T, OtherAllocator > &other)
 Copy constructor. Copy the data from other vector.
 
 PartitionedVector (const PartitionedVector< T, Allocator > &other)
 Copy constructor for a given type (to satisfy the rule of five)
 
 PartitionedVector (PartitionedVector< T, Allocator > &&other)
 Move constructor.
 
template<typename U>
 PartitionedVector (PartitionedSpan< U > other)
 
PartitionedVectoroperator= (const PartitionedVector< T, Allocator > &other)
 Copy assignment operator.
 
PartitionedVectoroperator= (PartitionedVector< T, Allocator > &&other)
 Move assignment operator.
 
gsl::span< T > operator[] (size_t i)
 Access data at partition i.
 
gsl::span< const T > operator[] (size_t i) const
 Access data at partition i.
 
uint32_t Address (size_t i) const
 Get the hardware address of partition i.
 
void Clear ()
 Clears the vector.
 
std::pair< gsl::span< T >, uint32_t > Partition (size_t i)
 Get a pair of the data and the hardware address of partition i.
 
std::pair< gsl::span< const T >, uint32_t > Partition (size_t i) const
 Get a pair of the data and the hardware address of partition i.
 
size_t NPartitions () const
 Get the number of partitions.
 
size_t Size (size_t i) const
 Get the size of partition i.
 
size_t NElements () const
 Get the total number of elements in the container across all partitions.
 
size_t SizeBytes () const
 Return total size in bytes of the underlying data.
 
gsl::span< T > Data ()
 Get the underlying data.
 
gsl::span< const T > Data () const
 Get the underlying data.
 
const std::vector< uint32_t > & Addresses () const
 Get the addresses.
 
const std::vector< size_t > & Offsets () const
 Get the underlying offsets.
 

Private Member Functions

void EnsureDimensions () const
 
void EnsureBounds (size_t i) const
 
void ComputeOffsets (gsl::span< const size_t > sizes)
 
size_t UnsafeSize (size_t i) const
 
gsl::span< T > UnsafePartitionSpan (size_t i)
 
gsl::span< const T > UnsafePartitionSpan (size_t i) const
 
template<class Archive>
void serialize (Archive &ar, unsigned int)
 

Private Attributes

Container_t fData
 Data.
 
std::vector< size_t > fOffsets
 Offsets of the partitions in fData.
 
std::vector< uint32_t > fAddresses
 Addresses of the partitions.
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename T, class Allocator = std::allocator<T>>
class cbm::PartitionedVector< T, Allocator >

A vector that is partitioned into multiple subvectors.

Template Parameters
TType of the elements
AllocatorAllocator for the underlying container
Note
The underlying container is contiguous in memory.

Definition at line 29 of file PartitionedVector.h.

Member Typedef Documentation

◆ Container_t

template<typename T, class Allocator = std::allocator<T>>
using cbm::PartitionedVector< T, Allocator >::Container_t = std::vector<T, Allocator>

Definition at line 32 of file PartitionedVector.h.

Constructor & Destructor Documentation

◆ PartitionedVector() [1/6]

template<typename T, class Allocator = std::allocator<T>>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( )
inline

Default constructor. Creates an empty vector.

Definition at line 37 of file PartitionedVector.h.

◆ PartitionedVector() [2/6]

template<typename T, class Allocator = std::allocator<T>>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( Container_t && data,
gsl::span< const size_t > sizes,
gsl::span< const uint32_t > addresses )
inline

Constructor. Creates a vector with n partitions.

Parameters
dataUnderlying data. Assusmes that the data is already partitioned and takes ownership of it.
sizesSizes of each partitions
addressesHardware addresses of each partition
Note
Requires sizes.size() == addresses.size()

Definition at line 48 of file PartitionedVector.h.

◆ PartitionedVector() [3/6]

template<typename T, class Allocator = std::allocator<T>>
template<typename OtherAllocator>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( const PartitionedVector< T, OtherAllocator > & other)
inline

Copy constructor. Copy the data from other vector.

Definition at line 61 of file PartitionedVector.h.

◆ PartitionedVector() [4/6]

template<typename T, class Allocator = std::allocator<T>>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( const PartitionedVector< T, Allocator > & other)
inline

Copy constructor for a given type (to satisfy the rule of five)

Definition at line 74 of file PartitionedVector.h.

◆ PartitionedVector() [5/6]

template<typename T, class Allocator = std::allocator<T>>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( PartitionedVector< T, Allocator > && other)
inline

Move constructor.

Definition at line 85 of file PartitionedVector.h.

◆ PartitionedVector() [6/6]

template<typename T, class Allocator = std::allocator<T>>
template<typename U>
cbm::PartitionedVector< T, Allocator >::PartitionedVector ( PartitionedSpan< U > other)
inline

Definition at line 95 of file PartitionedVector.h.

Member Function Documentation

◆ Address()

template<typename T, class Allocator = std::allocator<T>>
uint32_t cbm::PartitionedVector< T, Allocator >::Address ( size_t i) const
inline

Get the hardware address of partition i.

Definition at line 151 of file PartitionedVector.h.

Referenced by PartitionedVectorTest::Ensure(), and TEST_F().

◆ Addresses()

template<typename T, class Allocator = std::allocator<T>>
const std::vector< uint32_t > & cbm::PartitionedVector< T, Allocator >::Addresses ( ) const
inline

Get the addresses.

Definition at line 223 of file PartitionedVector.h.

◆ Clear()

template<typename T, class Allocator = std::allocator<T>>
void cbm::PartitionedVector< T, Allocator >::Clear ( )
inline

Clears the vector.

Definition at line 160 of file PartitionedVector.h.

◆ ComputeOffsets()

template<typename T, class Allocator = std::allocator<T>>
void cbm::PartitionedVector< T, Allocator >::ComputeOffsets ( gsl::span< const size_t > sizes)
inlineprivate

◆ Data() [1/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< T > cbm::PartitionedVector< T, Allocator >::Data ( )
inline

Get the underlying data.

Definition at line 213 of file PartitionedVector.h.

◆ Data() [2/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< const T > cbm::PartitionedVector< T, Allocator >::Data ( ) const
inline

Get the underlying data.

Definition at line 218 of file PartitionedVector.h.

◆ EnsureBounds()

◆ EnsureDimensions()

◆ NElements()

template<typename T, class Allocator = std::allocator<T>>
size_t cbm::PartitionedVector< T, Allocator >::NElements ( ) const
inline

Get the total number of elements in the container across all partitions.

Definition at line 203 of file PartitionedVector.h.

Referenced by PartitionedVectorTest::Ensure(), and TEST_F().

◆ NPartitions()

template<typename T, class Allocator = std::allocator<T>>
size_t cbm::PartitionedVector< T, Allocator >::NPartitions ( ) const
inline

Get the number of partitions.

Definition at line 189 of file PartitionedVector.h.

Referenced by PartitionedVectorTest::Ensure(), and TEST_F().

◆ Offsets()

template<typename T, class Allocator = std::allocator<T>>
const std::vector< size_t > & cbm::PartitionedVector< T, Allocator >::Offsets ( ) const
inline

Get the underlying offsets.

Definition at line 228 of file PartitionedVector.h.

◆ operator=() [1/2]

template<typename T, class Allocator = std::allocator<T>>
PartitionedVector & cbm::PartitionedVector< T, Allocator >::operator= ( const PartitionedVector< T, Allocator > & other)
inline

Copy assignment operator.

Definition at line 106 of file PartitionedVector.h.

◆ operator=() [2/2]

template<typename T, class Allocator = std::allocator<T>>
PartitionedVector & cbm::PartitionedVector< T, Allocator >::operator= ( PartitionedVector< T, Allocator > && other)
inline

Move assignment operator.

Definition at line 119 of file PartitionedVector.h.

◆ operator[]() [1/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< T > cbm::PartitionedVector< T, Allocator >::operator[] ( size_t i)
inline

Access data at partition i.

Definition at line 133 of file PartitionedVector.h.

◆ operator[]() [2/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< const T > cbm::PartitionedVector< T, Allocator >::operator[] ( size_t i) const
inline

Access data at partition i.

Definition at line 142 of file PartitionedVector.h.

◆ Partition() [1/2]

template<typename T, class Allocator = std::allocator<T>>
std::pair< gsl::span< T >, uint32_t > cbm::PartitionedVector< T, Allocator >::Partition ( size_t i)
inline

Get a pair of the data and the hardware address of partition i.

Definition at line 171 of file PartitionedVector.h.

Referenced by PartitionedVectorTest::Ensure(), and TEST_F().

◆ Partition() [2/2]

template<typename T, class Allocator = std::allocator<T>>
std::pair< gsl::span< const T >, uint32_t > cbm::PartitionedVector< T, Allocator >::Partition ( size_t i) const
inline

Get a pair of the data and the hardware address of partition i.

Definition at line 180 of file PartitionedVector.h.

◆ serialize()

template<typename T, class Allocator = std::allocator<T>>
template<class Archive>
void cbm::PartitionedVector< T, Allocator >::serialize ( Archive & ar,
unsigned int  )
inlineprivate

Definition at line 276 of file PartitionedVector.h.

◆ Size()

template<typename T, class Allocator = std::allocator<T>>
size_t cbm::PartitionedVector< T, Allocator >::Size ( size_t i) const
inline

Get the size of partition i.

Definition at line 194 of file PartitionedVector.h.

Referenced by PartitionedVectorTest::Ensure(), and TEST_F().

◆ SizeBytes()

template<typename T, class Allocator = std::allocator<T>>
size_t cbm::PartitionedVector< T, Allocator >::SizeBytes ( ) const
inline

Return total size in bytes of the underlying data.

Definition at line 208 of file PartitionedVector.h.

◆ UnsafePartitionSpan() [1/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< T > cbm::PartitionedVector< T, Allocator >::UnsafePartitionSpan ( size_t i)
inlineprivate

◆ UnsafePartitionSpan() [2/2]

template<typename T, class Allocator = std::allocator<T>>
gsl::span< const T > cbm::PartitionedVector< T, Allocator >::UnsafePartitionSpan ( size_t i) const
inlineprivate

Definition at line 267 of file PartitionedVector.h.

◆ UnsafeSize()

template<typename T, class Allocator = std::allocator<T>>
size_t cbm::PartitionedVector< T, Allocator >::UnsafeSize ( size_t i) const
inlineprivate

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<typename T, class Allocator = std::allocator<T>>
friend class boost::serialization::access
friend

Definition at line 273 of file PartitionedVector.h.

Member Data Documentation

◆ fAddresses

template<typename T, class Allocator = std::allocator<T>>
std::vector<uint32_t> cbm::PartitionedVector< T, Allocator >::fAddresses
private

Addresses of the partitions.

Definition at line 234 of file PartitionedVector.h.

Referenced by cbm::PartitionedVector< T, PODAllocator< T > >::operator=().

◆ fData

template<typename T, class Allocator = std::allocator<T>>
Container_t cbm::PartitionedVector< T, Allocator >::fData
private

◆ fOffsets

template<typename T, class Allocator = std::allocator<T>>
std::vector<size_t> cbm::PartitionedVector< T, Allocator >::fOffsets
private

Offsets of the partitions in fData.

Definition at line 233 of file PartitionedVector.h.

Referenced by cbm::PartitionedVector< T, PODAllocator< T > >::operator=().


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