ATLAS Offline Software
Loading...
Searching...
No Matches
ArrayStore< IdType, StorageType > Class Template Reference

Access and manipulate an indexed storage. More...

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

Private Attributes

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

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") { }
std::string m_tag
The tag std::string.
Definition ArrayStore.h:80

◆ 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) { }
const std::string & tag() const
Tag accessor.
Definition ArrayStore.h:135

◆ ~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(); }
BufferMap m_bufmap
The std::map.
Definition ArrayStore.h:81

◆ cbegin()

template<typename IdType, typename StorageType>
ArrayStore< IdType, StorageType >::map_citr ArrayStore< IdType, StorageType >::cbegin ( ) const
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 ( ) const
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 {
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));
160 dbg();
161 this->clear();
162 int i(-tmp.size());
163 for (;i<(int)tmp.size();i++){
164 bool first(true);
167 for ( pos=indexmap.lower_bound(i); pos!=indexmap.upper_bound(i); ++pos){
168 if (first){
169 first=false;
170 shared_id=pos->second;
172 } else
173 this->share(pos->second,shared_id);
174 }
175 }
176}
Access and manipulate an indexed storage.
Definition ArrayStore.h:32
void dbg() const
print method
Definition ArrayStore.h:118
void push_back(const IdType &ident, const StorageType &value)
makes new index
Definition ArrayStore.h:100
void clear()
remove all indices
Definition ArrayStore.h:97
void share(const IdType &ident, const IdType &referenceIdent)
makes index ident share data with referenceIdent
Definition ArrayStore.h:127
std::vector< StorageType > m_buf
The object stored in each second element.
Definition ArrayStore.h:82
BufferMap::const_iterator map_citr
Definition ArrayStore.h:37

◆ 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 ( ) const
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 {
131 }
132}
bool existID(const IdType &ident)
returns flag for index existing in the std::map
Definition ArrayStore.h:112

◆ 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 ( ) const
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: