CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
MultiVectorManager< T > Class Template Reference

#include <MultiVectorManager.h>

Classes

class  Iterator
 

Public Member Functions

void addVector (std::span< const T > vec)
 
Iterator begin () const
 
Iterator end () const
 
size_t getGlobalIndex (size_t vectorIndex, size_t localIndex) const
 
std::pair< size_t, size_t > getVectorAndLocalIndex (size_t globalIndex) const
 
Toperator[] (size_t globalIndex)
 
const Toperator[] (size_t globalIndex) const
 
size_t size () const
 

Private Attributes

std::vector< size_t > offsets
 
size_t totalSize = 0
 
std::vector< std::span< const T > > vectors
 

Detailed Description

template<typename T>
class MultiVectorManager< T >

Definition at line 11 of file MultiVectorManager.h.

Member Function Documentation

◆ addVector()

template<typename T>
void MultiVectorManager< T >::addVector ( std::span< const T vec)
inline

◆ begin()

template<typename T>
Iterator MultiVectorManager< T >::begin ( void  ) const
inline

Definition at line 75 of file MultiVectorManager.h.

75 { return Iterator(*this, 0); }
TGeoIterator Iterator

◆ end()

template<typename T>
Iterator MultiVectorManager< T >::end ( void  ) const
inline

Definition at line 77 of file MultiVectorManager.h.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

77 { return Iterator(*this, totalSize); }
TGeoIterator Iterator

◆ getGlobalIndex()

template<typename T>
size_t MultiVectorManager< T >::getGlobalIndex ( size_t  vectorIndex,
size_t  localIndex 
) const
inline

Definition at line 33 of file MultiVectorManager.h.

33  {
34  assert(vectorIndex < vectors.size() && "Vector index out of range");
35 
36  const auto& vec = vectors[vectorIndex];
37  assert(localIndex < vec.size() && "Local index out of range");
38 
39  return offsets[vectorIndex] + localIndex;
40  }
assert(be >=bs)
std::vector< size_t > offsets
std::vector< std::span< const T > > vectors

◆ getVectorAndLocalIndex()

template<typename T>
std::pair<size_t, size_t> MultiVectorManager< T >::getVectorAndLocalIndex ( size_t  globalIndex) const
inline

Definition at line 42 of file MultiVectorManager.h.

42  {
43  assert(globalIndex < totalSize && "Global index out of range");
44 
45  auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
46  size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
47  size_t localIndex = globalIndex - offsets[vectorIndex];
48 
49  return {vectorIndex, localIndex};
50  }
assert(be >=bs)
std::vector< size_t > offsets

◆ operator[]() [1/2]

template<typename T>
T& MultiVectorManager< T >::operator[] ( size_t  globalIndex)
inline

Definition at line 19 of file MultiVectorManager.h.

19  {
20  return const_cast<T&>(static_cast<const MultiVectorManager*>(this)->operator[](globalIndex));
21  }
long double T

◆ operator[]() [2/2]

template<typename T>
const T& MultiVectorManager< T >::operator[] ( size_t  globalIndex) const
inline

Definition at line 23 of file MultiVectorManager.h.

23  {
24  assert(globalIndex < totalSize && "Global index out of range");
25 
26  auto it = std::upper_bound(offsets.begin(), offsets.end(), globalIndex);
27  size_t vectorIndex = std::distance(offsets.begin(), it) - 1;
28  size_t localIndex = globalIndex - offsets[vectorIndex];
29 
30  return vectors[vectorIndex][localIndex];
31  }
assert(be >=bs)
std::vector< size_t > offsets
std::vector< std::span< const T > > vectors

◆ size()

template<typename T>
size_t MultiVectorManager< T >::size ( void  ) const
inline

Member Data Documentation

◆ offsets

template<typename T>
std::vector<size_t> MultiVectorManager< T >::offsets
private

◆ totalSize

template<typename T>
size_t MultiVectorManager< T >::totalSize = 0
private

◆ vectors

template<typename T>
std::vector<std::span<const T> > MultiVectorManager< T >::vectors
private