CbmRoot
|
A vector that is partitioned into multiple subvectors. More...
#include <PartitionedVector.h>
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 >, u32 > | Partition (size_t i) |
Get a pair of the data and the hardware address of partition i. | |
std::pair< gsl::span< const T >, u32 > | 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< 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< u32 > | fAdresses |
Friends | |
class | boost::serialization::access |
A vector that is partitioned into multiple subvectors.
T | Type of the elements |
Allocator | Allocator for the underlying container |
Definition at line 30 of file PartitionedVector.h.
using cbm::algo::PartitionedVector< T, Allocator >::Container_t = std::vector<T, Allocator> |
Definition at line 33 of file PartitionedVector.h.
|
inline |
Default constructor. Creates an empty vector.
Definition at line 38 of file PartitionedVector.h.
|
inline |
Constructor. Creates a vector with n partitions.
data | Underlying data. Assusmes that the data is already partitioned and takes ownership of it. |
sizes | Sizes of each partitions |
addresses | Hardware addresses of each partition |
Definition at line 49 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::ComputeOffsets(), and cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions().
|
inline |
Copy constructor. Copy the data from other vector.
Definition at line 62 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions().
|
inline |
Definition at line 73 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions().
|
inline |
Get the hardware address of partition i.
Definition at line 102 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), and cbm::algo::PartitionedVector< T, Allocator >::fAdresses.
Referenced by PartitionedVectorTest::Ensure(), and TEST_F().
|
inline |
Get the addresses.
Definition at line 163 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fAdresses.
|
inlineprivate |
Definition at line 193 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fOffsets.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::PartitionedVector().
|
inline |
Get the underlying data.
Definition at line 153 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fData.
|
inline |
Get the underlying data.
Definition at line 158 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fData.
|
inlineprivate |
Definition at line 188 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fAdresses.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::Address(), cbm::algo::PartitionedVector< T, Allocator >::operator[](), cbm::algo::PartitionedVector< T, Allocator >::operator[](), cbm::algo::PartitionedVector< T, Allocator >::Partition(), cbm::algo::PartitionedVector< T, Allocator >::Partition(), and cbm::algo::PartitionedVector< T, Allocator >::Size().
|
inlineprivate |
Definition at line 175 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fAdresses, cbm::algo::PartitionedVector< T, Allocator >::fData, and cbm::algo::PartitionedVector< T, Allocator >::fOffsets.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::PartitionedVector(), cbm::algo::PartitionedVector< T, Allocator >::PartitionedVector(), and cbm::algo::PartitionedVector< T, Allocator >::PartitionedVector().
|
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().
|
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().
|
inline |
Get the underlying offsets.
Definition at line 168 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fOffsets.
|
inline |
Access data at partition i.
Definition at line 84 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
|
inline |
Access data at partition i.
Definition at line 93 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
|
inline |
Get a pair of the data and the hardware address of partition i.
Definition at line 111 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), cbm::algo::PartitionedVector< T, Allocator >::fAdresses, and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
Referenced by PartitionedVectorTest::Ensure(), and TEST_F().
|
inline |
Get a pair of the data and the hardware address of partition i.
Definition at line 120 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), cbm::algo::PartitionedVector< T, Allocator >::fAdresses, and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
|
inlineprivate |
Definition at line 215 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fAdresses, cbm::algo::PartitionedVector< T, Allocator >::fData, and cbm::algo::PartitionedVector< T, Allocator >::fOffsets.
|
inline |
Get the size of partition i.
Definition at line 134 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafeSize().
Referenced by PartitionedVectorTest::Ensure(), and TEST_F().
|
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.
|
inlineprivate |
Definition at line 204 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fData, cbm::algo::PartitionedVector< T, Allocator >::fOffsets, and cbm::algo::PartitionedVector< T, Allocator >::UnsafeSize().
Referenced by cbm::algo::PartitionedVector< T, Allocator >::operator[](), cbm::algo::PartitionedVector< T, Allocator >::operator[](), cbm::algo::PartitionedVector< T, Allocator >::Partition(), and cbm::algo::PartitionedVector< T, Allocator >::Partition().
|
inlineprivate |
Definition at line 206 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fData, cbm::algo::PartitionedVector< T, Allocator >::fOffsets, and cbm::algo::PartitionedVector< T, Allocator >::UnsafeSize().
|
inlineprivate |
Definition at line 202 of file PartitionedVector.h.
References cbm::algo::PartitionedVector< T, Allocator >::fOffsets.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::Size(), cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
|
friend |
Definition at line 212 of file PartitionedVector.h.
|
private |
Definition at line 173 of file PartitionedVector.h.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::Address(), cbm::algo::PartitionedVector< T, Allocator >::Addresses(), cbm::algo::PartitionedVector< T, Allocator >::EnsureBounds(), cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions(), cbm::algo::PartitionedVector< T, Allocator >::NPartitions(), cbm::algo::PartitionedVector< T, Allocator >::Partition(), cbm::algo::PartitionedVector< T, Allocator >::Partition(), and cbm::algo::PartitionedVector< T, Allocator >::serialize().
|
private |
Definition at line 171 of file PartitionedVector.h.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::Data(), cbm::algo::PartitionedVector< T, Allocator >::Data(), cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions(), cbm::algo::PartitionedVector< T, Allocator >::NElements(), cbm::algo::PartitionedVector< T, Allocator >::serialize(), cbm::algo::PartitionedVector< T, Allocator >::SizeBytes(), cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan().
|
private |
Definition at line 172 of file PartitionedVector.h.
Referenced by cbm::algo::PartitionedVector< T, Allocator >::ComputeOffsets(), cbm::algo::PartitionedVector< T, Allocator >::EnsureDimensions(), cbm::algo::PartitionedVector< T, Allocator >::Offsets(), cbm::algo::PartitionedVector< T, Allocator >::serialize(), cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan(), cbm::algo::PartitionedVector< T, Allocator >::UnsafePartitionSpan(), and cbm::algo::PartitionedVector< T, Allocator >::UnsafeSize().