ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
ArrayStore< IdType, StorageType > Class Template Reference

#include <ArrayStore.h>

Collaboration diagram for ArrayStore< IdType, StorageType >:

Public Types

typedef std::less< IdType > lessp
 
typedef std::map< IdType, int, lesspBufferMap
 
typedef BufferMap::const_iterator map_citr
 
typedef BufferMap::iterator map_itr
 

Public Member Functions

 ArrayStore ()
 constructors, optionally with a tag More...
 
 ArrayStore (const std::string &tag)
 
virtual ~ArrayStore ()
 destructor
More...
 
const std::string & tag () const
 Tag accessor. More...
 
int numberOfIDs ()
 Size accessor. More...
 
const StorageType & operator[] (const IdType &ident) const
 Overload [] const access. More...
 
bool sharedID (const IdType &ident)
 returns flag for index sharing data More...
 
bool existID (const IdType &ident)
 returns flag for index existing in the std::map More...
 
void dbg () const
 print method More...
 
map_citr cbegin () const
 begin/end const iterators More...
 
map_citr cend () const
 
StorageType & operator[] (const IdType &ident)
 Overload [] modifier. More...
 
void share (const IdType &ident, const IdType &referenceIdent)
 makes index ident share data with referenceIdent More...
 
void push_back (const IdType &ident, const StorageType &value)
 makes new index More...
 
void removeID (const IdType &ident)
 remove index More...
 
void clear ()
 remove all indices More...
 
void cleanUp ()
 remove data with no index pointing to it More...
 
map_itr begin ()
 begin/end iterators More...
 
map_itr end ()
 

Private Attributes

std::string m_tag
 The tag std::string. More...
 
BufferMap m_bufmap
 The std::map. More...
 
std::vector< StorageType > m_buf
 The object stored in each second element. More...
 

Detailed Description

template<typename IdType = int, typename StorageType = std::vector<float>>
class ArrayStore< IdType, StorageType >

Access and manipulate an indexed storage

Author
Jorgen Beck Hansen

Definition at line 32 of file ArrayStore.h.

Member Typedef Documentation

◆ BufferMap

template<typename IdType = int, typename StorageType = std::vector<float>>
typedef std::map<IdType,int,lessp> ArrayStore< IdType, StorageType >::BufferMap

Definition at line 36 of file ArrayStore.h.

◆ lessp

template<typename IdType = int, typename StorageType = std::vector<float>>
typedef std::less<IdType> ArrayStore< IdType, StorageType >::lessp

Definition at line 35 of file ArrayStore.h.

◆ map_citr

template<typename IdType = int, typename StorageType = std::vector<float>>
typedef BufferMap::const_iterator ArrayStore< IdType, StorageType >::map_citr

Definition at line 37 of file ArrayStore.h.

◆ map_itr

template<typename IdType = int, typename StorageType = std::vector<float>>
typedef BufferMap::iterator ArrayStore< IdType, StorageType >::map_itr

Definition at line 38 of file ArrayStore.h.

Constructor & Destructor Documentation

◆ ArrayStore() [1/2]

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::ArrayStore
inline

constructors, optionally with a tag

Definition at line 88 of file ArrayStore.h.

88 : m_tag("Undefined") { }

◆ ArrayStore() [2/2]

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::ArrayStore ( const std::string &  tag)
inline

Definition at line 91 of file ArrayStore.h.

91 : m_tag(tag) { }

◆ ~ArrayStore()

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::~ArrayStore
inlinevirtual

destructor

Definition at line 94 of file ArrayStore.h.

94 {}

Member Function Documentation

◆ begin()

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::map_itr ArrayStore< IdType, StorageType >::begin
inline

begin/end iterators

Definition at line 138 of file ArrayStore.h.

138 { return m_bufmap.begin(); }

◆ cbegin()

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::map_citr ArrayStore< IdType, StorageType >::cbegin
inline

begin/end const iterators

Definition at line 144 of file ArrayStore.h.

144 { return m_bufmap.begin(); }

◆ cend()

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::map_citr ArrayStore< IdType, StorageType >::cend
inline

Definition at line 147 of file ArrayStore.h.

147 { return m_bufmap.end(); }

◆ cleanUp()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::cleanUp

remove data with no index pointing to it

Definition at line 153 of file ArrayStore.h.

153  {
154  std::multimap<int,IdType> indexmap;
155 
156  map_citr itr=m_bufmap.begin();
157  for (;itr!=m_bufmap.end();++itr)
158  indexmap.insert(std::pair<int,IdType>(std::abs(itr->second),itr->first));
159  std::vector<StorageType> tmp(m_buf);
160  dbg();
161  this->clear();
162  int i(-tmp.size());
163  for (;i<(int)tmp.size();i++){
164  bool first(true);
165  IdType shared_id;
167  for ( pos=indexmap.lower_bound(i); pos!=indexmap.upper_bound(i); ++pos){
168  if (first){
169  first=false;
170  shared_id=pos->second;
171  this->push_back(shared_id,tmp[std::abs(i)]);
172  } else
173  this->share(pos->second,shared_id);
174  }
175  }
176 }

◆ clear()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::clear
inline

remove all indices

Definition at line 97 of file ArrayStore.h.

97 {m_bufmap.clear(); m_buf.clear(); }

◆ dbg()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::dbg
inline

print method

Definition at line 118 of file ArrayStore.h.

118 {std::cout << "dbg:" << m_bufmap.size() << " " << m_buf.size() << std::endl;}

◆ end()

template<typename IdType , typename StorageType >
ArrayStore< IdType, StorageType >::map_itr ArrayStore< IdType, StorageType >::end
inline

Definition at line 141 of file ArrayStore.h.

141 { return m_bufmap.end(); }

◆ existID()

template<typename IdType , typename StorageType >
bool ArrayStore< IdType, StorageType >::existID ( const IdType &  ident)
inline

returns flag for index existing in the std::map

Definition at line 112 of file ArrayStore.h.

112 { return m_bufmap.find(ident)!=m_bufmap.end(); }

◆ numberOfIDs()

template<typename IdType , typename StorageType >
int ArrayStore< IdType, StorageType >::numberOfIDs
inline

Size accessor.

Definition at line 106 of file ArrayStore.h.

106 { return m_bufmap.size(); }

◆ operator[]() [1/2]

template<typename IdType , typename StorageType >
StorageType & ArrayStore< IdType, StorageType >::operator[] ( const IdType &  ident)
inline

Overload [] modifier.

Definition at line 124 of file ArrayStore.h.

124 {return m_buf[std::abs(m_bufmap[ident])]; }

◆ operator[]() [2/2]

template<typename IdType , typename StorageType >
const StorageType & ArrayStore< IdType, StorageType >::operator[] ( const IdType &  ident) const
inline

Overload [] const access.

Definition at line 121 of file ArrayStore.h.

121 {return m_buf[std::abs(m_bufmap.find(ident)->second)]; }

◆ push_back()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::push_back ( const IdType &  ident,
const StorageType &  value 
)
inline

makes new index

Definition at line 100 of file ArrayStore.h.

100  {
101  m_buf.push_back(value);
102  m_bufmap[ident]= m_buf.size()-1;
103 }

◆ removeID()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::removeID ( const IdType &  ident)
inline

remove index

Definition at line 109 of file ArrayStore.h.

109 { m_bufmap.erase(ident); }

◆ share()

template<typename IdType , typename StorageType >
void ArrayStore< IdType, StorageType >::share ( const IdType &  ident,
const IdType &  referenceIdent 
)
inline

makes index ident share data with referenceIdent

Definition at line 127 of file ArrayStore.h.

127  {
128  if (existID(referenceIdent)){
129  m_bufmap[ident] = -std::abs(m_bufmap[referenceIdent]);
130  m_bufmap[referenceIdent] = -std::abs(m_bufmap[referenceIdent]);
131  }
132 }

◆ sharedID()

template<typename IdType , typename StorageType >
bool ArrayStore< IdType, StorageType >::sharedID ( const IdType &  ident)
inline

returns flag for index sharing data

Definition at line 115 of file ArrayStore.h.

115 { return existID(ident)? m_bufmap.find(ident)->second <0 : false; }

◆ tag()

template<typename IdType , typename StorageType >
const std::string & ArrayStore< IdType, StorageType >::tag
inline

Tag accessor.

Definition at line 135 of file ArrayStore.h.

135 {return m_tag;}

Member Data Documentation

◆ m_buf

template<typename IdType = int, typename StorageType = std::vector<float>>
std::vector<StorageType> ArrayStore< IdType, StorageType >::m_buf
private

The object stored in each second element.

Definition at line 82 of file ArrayStore.h.

◆ m_bufmap

template<typename IdType = int, typename StorageType = std::vector<float>>
BufferMap ArrayStore< IdType, StorageType >::m_bufmap
private

The std::map.

Definition at line 81 of file ArrayStore.h.

◆ m_tag

template<typename IdType = int, typename StorageType = std::vector<float>>
std::string ArrayStore< IdType, StorageType >::m_tag
private

The tag std::string.

Definition at line 80 of file ArrayStore.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ArrayStore::map_citr
BufferMap::const_iterator map_citr
Definition: ArrayStore.h:37
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ArrayStore::dbg
void dbg() const
print method
Definition: ArrayStore.h:118
ArrayStore::share
void share(const IdType &ident, const IdType &referenceIdent)
makes index ident share data with referenceIdent
Definition: ArrayStore.h:127
ArrayStore::tag
const std::string & tag() const
Tag accessor.
Definition: ArrayStore.h:135
athena.value
value
Definition: athena.py:124
ArrayStore::push_back
void push_back(const IdType &ident, const StorageType &value)
makes new index
Definition: ArrayStore.h:100
ArrayStore::existID
bool existID(const IdType &ident)
returns flag for index existing in the std::map
Definition: ArrayStore.h:112
lumiFormat.i
int i
Definition: lumiFormat.py:85
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ArrayStore::m_tag
std::string m_tag
The tag std::string.
Definition: ArrayStore.h:80
ArrayStore::clear
void clear()
remove all indices
Definition: ArrayStore.h:97
ArrayStore::m_bufmap
BufferMap m_bufmap
The std::map.
Definition: ArrayStore.h:81
ArrayStore::m_buf
std::vector< StorageType > m_buf
The object stored in each second element.
Definition: ArrayStore.h:82
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DeMoScan.first
bool first
Definition: DeMoScan.py:536