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

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

#include <PartitionedVector.h>

Inheritance diagram for cbm::algo::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 u32 > 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.
 
template<typename U >
 PartitionedVector (PartitionedSpan< U > other)
 
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.
 
u32 Address (size_t i) const
 Get the hardware address of partition i.
 
std::pair< gsl::span< T >, u32Partition (size_t i)
 Get a pair of the data and the hardware address of partition i.
 
std::pair< gsl::span< const T >, u32Partition (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< u32 > & 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
 
std::vector< size_t > fOffsets
 
std::vector< u32fAdresses
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename T, class Allocator = std::allocator<T>>
class cbm::algo::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 30 of file PartitionedVector.h.

Member Typedef Documentation

◆ Container_t

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

Definition at line 33 of file PartitionedVector.h.

Constructor & Destructor Documentation

◆ PartitionedVector() [1/4]

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

Default constructor. Creates an empty vector.

Definition at line 38 of file PartitionedVector.h.

◆ PartitionedVector() [2/4]

template<typename T , class Allocator = std::allocator<T>>
cbm::algo::PartitionedVector< T, Allocator >::PartitionedVector ( Container_t && data,
gsl::span< const size_t > sizes,
gsl::span< const u32 > 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 49 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::ComputeOffsets(), and cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions().

◆ PartitionedVector() [3/4]

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

Copy constructor. Copy the data from other vector.

Definition at line 62 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions().

◆ PartitionedVector() [4/4]

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

Member Function Documentation

◆ Address()

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

◆ Addresses()

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

Get the addresses.

Definition at line 163 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fAdresses.

◆ ComputeOffsets()

template<typename T , class Allocator = std::allocator<T>>
void cbm::algo::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::algo::PartitionedVector< T, Allocator >::Data ( )
inline

Get the underlying data.

Definition at line 153 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fData.

◆ Data() [2/2]

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

Get the underlying data.

Definition at line 158 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fData.

◆ EnsureBounds()

◆ EnsureDimensions()

◆ NElements()

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

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

Definition at line 143 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fData.

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

◆ NPartitions()

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

Get the number of partitions.

Definition at line 129 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fAdresses.

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

◆ Offsets()

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

Get the underlying offsets.

Definition at line 168 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fOffsets.

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ Partition() [1/2]

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

◆ Partition() [2/2]

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

◆ serialize()

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

◆ Size()

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

◆ SizeBytes()

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

Return total size in bytes of the underlying data.

Definition at line 148 of file PartitionedVector.h.

References cbm::algo::PartitionedVector< T, Allocator >::fData.

◆ UnsafePartitionSpan() [1/2]

◆ UnsafePartitionSpan() [2/2]

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

◆ UnsafeSize()

template<typename T , class Allocator = std::allocator<T>>
size_t cbm::algo::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 212 of file PartitionedVector.h.

Member Data Documentation

◆ fAdresses

◆ fData

◆ fOffsets


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