CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
LayerHitMapCache::SimpleCache Class Reference

Public Types

using KeyType = int
 
using ValueType = RecHitsSortedInPhi
 

Public Member Functions

void add (KeyType key, ValueType *value)
 add object to cache. It is caller responsibility to check that object is not yet there. More...
 
void clear ()
 emptify cache, delete values associated to Key More...
 
void extend (const SimpleCache &other)
 
const ValueTypeget (KeyType key) const
 
void resize (int size)
 
 SimpleCache (unsigned int initSize)
 
 SimpleCache (SimpleCache &&rh)
 
 ~SimpleCache ()
 

Private Member Functions

 SimpleCache (const SimpleCache &)
 

Private Attributes

std::vector< mayown_ptr< ValueType > > theContainer
 

Detailed Description

Definition at line 18 of file LayerHitMapCache.h.

Member Typedef Documentation

Definition at line 21 of file LayerHitMapCache.h.

Definition at line 20 of file LayerHitMapCache.h.

Constructor & Destructor Documentation

LayerHitMapCache::SimpleCache::SimpleCache ( unsigned int  initSize)
inline

Definition at line 22 of file LayerHitMapCache.h.

22 : theContainer(initSize){}
std::vector< mayown_ptr< ValueType > > theContainer
LayerHitMapCache::SimpleCache::SimpleCache ( SimpleCache &&  rh)
inline

Definition at line 23 of file LayerHitMapCache.h.

23 : theContainer(std::move(rh.theContainer)) {}
std::vector< mayown_ptr< ValueType > > theContainer
def move(src, dest)
Definition: eostools.py:510
LayerHitMapCache::SimpleCache::~SimpleCache ( )
inline

Definition at line 24 of file LayerHitMapCache.h.

References clear().

24 { clear(); }
void clear()
emptify cache, delete values associated to Key
LayerHitMapCache::SimpleCache::SimpleCache ( const SimpleCache )
inlineprivate

Definition at line 49 of file LayerHitMapCache.h.

49 { }

Member Function Documentation

void LayerHitMapCache::SimpleCache::add ( KeyType  key,
ValueType value 
)
inline

add object to cache. It is caller responsibility to check that object is not yet there.

Definition at line 28 of file LayerHitMapCache.h.

References crabWrapper::key, resize(), and theContainer.

Referenced by LayerHitMapCache::operator()(), and counter.Counter::register().

28  {
29  if (key>=int(theContainer.size())) resize(key+1);
30  theContainer[key].reset(value);
31  }
std::vector< mayown_ptr< ValueType > > theContainer
Definition: value.py:1
void LayerHitMapCache::SimpleCache::clear ( void  )
inline

emptify cache, delete values associated to Key

Definition at line 43 of file LayerHitMapCache.h.

References theContainer, and findQualityFiles::v.

Referenced by LayerHitMapCache::clear(), and ~SimpleCache().

43  {
44  for ( auto & v : theContainer) { v.reset(); }
45  }
std::vector< mayown_ptr< ValueType > > theContainer
void LayerHitMapCache::SimpleCache::extend ( const SimpleCache other)
inline

Definition at line 32 of file LayerHitMapCache.h.

References get(), mps_fire::i, resize(), findQualityFiles::size, and theContainer.

Referenced by MatrixUtil.WF::__init__(), and LayerHitMapCache::extend().

32  {
33  // N.B. Here we assume that the lifetime of 'other' is longer than of 'this'.
34  if(other.theContainer.size() > theContainer.size())
35  resize(other.theContainer.size());
36 
37  for(size_t i=0, size=other.theContainer.size(); i != size; ++i) {
38  assert(get(i) == nullptr); // We don't want to override any existing value
39  theContainer[i].reset(*(other.get(i))); // pass by reference to denote that we don't own it
40  }
41  }
size
Write out results.
std::vector< mayown_ptr< ValueType > > theContainer
const ValueType* LayerHitMapCache::SimpleCache::get ( KeyType  key) const
inline
void LayerHitMapCache::SimpleCache::resize ( int  size)
inline

Member Data Documentation

std::vector<mayown_ptr<ValueType> > LayerHitMapCache::SimpleCache::theContainer
private

Definition at line 47 of file LayerHitMapCache.h.

Referenced by add(), clear(), extend(), get(), and resize().