ATLAS Offline Software
Loading...
Searching...
No Matches
FloatArrayStore Class Reference

class FloatArrayStore Access and manipulate an indexed storage of float vectors More...

#include <FloatArrayStore.h>

Collaboration diagram for FloatArrayStore:

Public Types

typedef std::less< Identifierlessp
typedef std::map< Identifier, int, lesspBufferMap
typedef BufferMap::const_iterator map_citr
typedef std::vector< std::vector< float > > Buffer

Public Member Functions

 FloatArrayStore ()
 constructors, optionally with a tag
 FloatArrayStore (const std::string &tag)
virtual ~FloatArrayStore ()
 destructor
FloatArrayStoreoperator= (FloatArrayStore &&other)
 move assignment
const std::string & tag () const
 Tag accessor.
int numberOfIDs () const
 Size accessor.
const std::vector< float > & operator[] (const Identifier &ident) const
 Overload [] const access.
bool sharedID (const Identifier &ident) const
 returns flag for index sharing data
bool existID (const Identifier &ident) const
 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
std::vector< float > & operator[] (const Identifier &ident)
 Overload [] modifier.
void share (const Identifier &ident, const Identifier &referenceIdent)
 makes index ident share data with referenceIdent
void push_back (const Identifier &ident, const std::vector< float > &value)
 makes new indices
void push_back (const std::vector< Identifier > &identvec, const std::vector< float > &value)
void removeID (const Identifier &ident)
 remove new index
void clear ()
 remove all
void cleanUp ()
 remove data with no index pointing to it
map_citr begin () const
 begin/end iterators
map_citr end () const
const Bufferbuffer () const
 return stored vector

Private Attributes

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

Detailed Description

class FloatArrayStore Access and manipulate an indexed storage of float vectors

Author
Jorgen Beck Hansen

Definition at line 34 of file FloatArrayStore.h.

Member Typedef Documentation

◆ Buffer

typedef std::vector< std::vector<float> > FloatArrayStore::Buffer

Definition at line 40 of file FloatArrayStore.h.

◆ BufferMap

Definition at line 38 of file FloatArrayStore.h.

◆ lessp

typedef std::less<Identifier> FloatArrayStore::lessp

Definition at line 37 of file FloatArrayStore.h.

◆ map_citr

typedef BufferMap::const_iterator FloatArrayStore::map_citr

Definition at line 39 of file FloatArrayStore.h.

Constructor & Destructor Documentation

◆ FloatArrayStore() [1/2]

FloatArrayStore::FloatArrayStore ( )
inline

constructors, optionally with a tag

Definition at line 97 of file FloatArrayStore.h.

97: m_tag("Undefined") { }
std::string m_tag
The tag std::string.

◆ FloatArrayStore() [2/2]

FloatArrayStore::FloatArrayStore ( const std::string & tag)
inline

Definition at line 99 of file FloatArrayStore.h.

99: m_tag(tag) { }
const std::string & tag() const
Tag accessor.

◆ ~FloatArrayStore()

FloatArrayStore::~FloatArrayStore ( )
inlinevirtual

destructor

Definition at line 111 of file FloatArrayStore.h.

111{}

Member Function Documentation

◆ begin()

FloatArrayStore::map_citr FloatArrayStore::begin ( ) const
inline

begin/end iterators

Definition at line 157 of file FloatArrayStore.h.

157{ return m_bufmap.begin(); }
BufferMap m_bufmap
The std::map.

◆ buffer()

const Buffer & FloatArrayStore::buffer ( ) const
inline

return stored vector

Definition at line 83 of file FloatArrayStore.h.

83{ return m_buf ; }
Buffer m_buf
The std::vector<float> stored in each second element.

◆ cbegin()

FloatArrayStore::map_citr FloatArrayStore::cbegin ( ) const
inline

begin/end const iterators

Definition at line 163 of file FloatArrayStore.h.

163{ return m_bufmap.begin(); }

◆ cend()

FloatArrayStore::map_citr FloatArrayStore::cend ( ) const
inline

Definition at line 165 of file FloatArrayStore.h.

165{ return m_bufmap.end(); }

◆ cleanUp()

void FloatArrayStore::cleanUp ( )

remove data with no index pointing to it

Definition at line 9 of file FloatArrayStore.cxx.

9 {
10 std::multimap<int,Identifier> indexmap;
11
12 map_citr itr=m_bufmap.begin();
13 for (;itr!=m_bufmap.end();++itr)
14 indexmap.insert(std::pair<int,Identifier>(std::abs(itr->second),itr->first));
15 std::vector< std::vector<float> > tmp(m_buf);
16 dbg();
17 this->clear();
18 int i(-tmp.size());
19 for (;i<(int)tmp.size();i++){
20 bool first(true);
21 Identifier shared_id;
22 std::multimap<int,Identifier>::iterator pos;
23 for ( pos=indexmap.lower_bound(i); pos!=indexmap.upper_bound(i); ++pos){
24 if (first){
25 first=false;
26 shared_id=pos->second;
27 this->push_back(shared_id,tmp[std::abs(i)]);
28 } else
29 this->share(pos->second,shared_id);
30 }
31 }
32}
void share(const Identifier &ident, const Identifier &referenceIdent)
makes index ident share data with referenceIdent
BufferMap::const_iterator map_citr
void clear()
remove all
void push_back(const Identifier &ident, const std::vector< float > &value)
makes new indices
void dbg() const
print method
bool first
Definition DeMoScan.py:534

◆ clear()

void FloatArrayStore::clear ( )
inline

remove all

Definition at line 113 of file FloatArrayStore.h.

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

◆ dbg()

void FloatArrayStore::dbg ( ) const

print method

Definition at line 34 of file FloatArrayStore.cxx.

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

◆ end()

FloatArrayStore::map_citr FloatArrayStore::end ( ) const
inline

Definition at line 160 of file FloatArrayStore.h.

160{ return m_bufmap.end(); }

◆ existID()

bool FloatArrayStore::existID ( const Identifier & ident) const
inline

returns flag for index existing in the std::map

Definition at line 134 of file FloatArrayStore.h.

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

◆ numberOfIDs()

int FloatArrayStore::numberOfIDs ( ) const
inline

Size accessor.

Definition at line 128 of file FloatArrayStore.h.

129{ return m_bufmap.size(); }

◆ operator=()

FloatArrayStore & FloatArrayStore::operator= ( FloatArrayStore && other)
inline

move assignment

Definition at line 101 of file FloatArrayStore.h.

101 {
102 if (this!=&other){
103 m_tag=std::move(other.m_tag);
104 m_bufmap = other.m_bufmap;//can't std::move a map, the keys are const
105 m_buf=std::move(other.m_buf);
106 }
107 return *this;
108}

◆ operator[]() [1/2]

std::vector< float > & FloatArrayStore::operator[] ( const Identifier & ident)
inline

Overload [] modifier.

Definition at line 143 of file FloatArrayStore.h.

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

◆ operator[]() [2/2]

const std::vector< float > & FloatArrayStore::operator[] ( const Identifier & ident) const
inline

Overload [] const access.

Definition at line 139 of file FloatArrayStore.h.

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

◆ push_back() [1/2]

void FloatArrayStore::push_back ( const Identifier & ident,
const std::vector< float > & value )
inline

makes new indices

Definition at line 115 of file FloatArrayStore.h.

116 {
117 m_buf.push_back(value);
118 m_bufmap[ident]= m_buf.size()-1;
119}
@ ident
Definition HitInfo.h:77

◆ push_back() [2/2]

void FloatArrayStore::push_back ( const std::vector< Identifier > & identvec,
const std::vector< float > & value )
inline

Definition at line 121 of file FloatArrayStore.h.

121 {
122 m_buf.push_back(value);
123 size_t index = m_buf.size()-1;
124 for(std::vector<Identifier>::const_iterator it = identvec.begin() ; it != identvec.end(); ++it)
125 m_bufmap[*it] = index ;
126}
str index
Definition DeMoScan.py:362

◆ removeID()

void FloatArrayStore::removeID ( const Identifier & ident)
inline

remove new index

Definition at line 131 of file FloatArrayStore.h.

132{ m_bufmap.erase(ident); }

◆ share()

void FloatArrayStore::share ( const Identifier & ident,
const Identifier & referenceIdent )
inline

makes index ident share data with referenceIdent

Definition at line 146 of file FloatArrayStore.h.

147 {
148 if (existID(referenceIdent)){
149 m_bufmap[ident] = -std::abs(m_bufmap[referenceIdent]);
150 m_bufmap[referenceIdent] = -std::abs(m_bufmap[referenceIdent]);
151 }
152}
bool existID(const Identifier &ident) const
returns flag for index existing in the std::map

◆ sharedID()

bool FloatArrayStore::sharedID ( const Identifier & ident) const
inline

returns flag for index sharing data

Definition at line 137 of file FloatArrayStore.h.

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

◆ tag()

const std::string & FloatArrayStore::tag ( ) const
inline

Tag accessor.

Definition at line 154 of file FloatArrayStore.h.

154{return m_tag;}

Member Data Documentation

◆ m_buf

Buffer FloatArrayStore::m_buf
private

The std::vector<float> stored in each second element.

Definition at line 90 of file FloatArrayStore.h.

◆ m_bufmap

BufferMap FloatArrayStore::m_bufmap
private

The std::map.

Definition at line 89 of file FloatArrayStore.h.

◆ m_tag

std::string FloatArrayStore::m_tag
private

The tag std::string.

Definition at line 88 of file FloatArrayStore.h.


The documentation for this class was generated from the following files: