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 (const std::vector< 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::vector< 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 ( const std::vector< T > &  vec)
inline

Definition at line 13 of file MultiVectorManager.h.

13  {
14  vectors.emplace_back(vec.begin(), vec.end());
15  offsets.push_back(totalSize);
16  totalSize += vec.size();
17  }
std::vector< std::vector< T > > vectors
std::vector< size_t > offsets

◆ 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  }
std::vector< std::vector< T > > vectors
assert(be >=bs)
std::vector< size_t > offsets

◆ getVectorAndLocalIndex()

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

Definition at line 44 of file MultiVectorManager.h.

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

◆ 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::vector<T> > MultiVectorManager< T >::vectors
private