CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ora::MultiIndexDataTrie Class Reference

#include <MultiIndexDataTrie.h>

Public Member Functions

size_t branchSize (const std::vector< int > &indexes, size_t depth=0) const
 
void clear ()
 
void lookupAndClear (const std::vector< int > &indexes, Record &rec)
 
 MultiIndexDataTrie ()
 
size_t push (const std::vector< int > &indexes, Record &data)
 
size_t size () const
 
size_t totalSize () const
 
virtual ~MultiIndexDataTrie ()
 

Private Attributes

std::vector< MultiIndexDataTrie * > m_children
 
Record m_data
 

Detailed Description

Definition at line 14 of file MultiIndexDataTrie.h.

Constructor & Destructor Documentation

ora::MultiIndexDataTrie::MultiIndexDataTrie ( )

Definition at line 8 of file MultiIndexDataTrie.cc.

8  :
9  m_children(),
10  m_data(){
11 
12 }
std::vector< MultiIndexDataTrie * > m_children
ora::MultiIndexDataTrie::~MultiIndexDataTrie ( )
virtual

Definition at line 14 of file MultiIndexDataTrie.cc.

References hitfit::clear().

14  {
15  clear();
16 }

Member Function Documentation

size_t ora::MultiIndexDataTrie::branchSize ( const std::vector< int > &  indexes,
size_t  depth = 0 
) const

Definition at line 112 of file MultiIndexDataTrie.cc.

References i, m_children, and ora::throwException().

112  {
113  if( depth > indexes.size() ) depth = indexes.size();
114  const MultiIndexDataTrie* trie = this;
115  for( size_t i=0;i<depth;i++){
116  if( indexes[i]+1 > (int)(trie->m_children.size())){
117  // empty leaf
118  if( i+2>=indexes.size()) return 0;
119  // empty branches are not expected!
120  std::stringstream mess;
121  mess << "1 Index["<<i<<"] is out of bound.";
122  throwException( mess.str(),"MultiIndexDataTrie::branchSize" );
123  }
124  trie = trie->m_children[indexes[i]];
125  if( !trie ){
126  std::stringstream mess;
127  mess << "Slot for index["<<i<<"] is empty.";
128  throwException( mess.str(),"MultiIndexDataTrie::branchSize" );
129  }
130  }
131  return trie->m_children.size();
132 }
int i
Definition: DBlmapReader.cc:9
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::MultiIndexDataTrie::clear ( void  )
void ora::MultiIndexDataTrie::lookupAndClear ( const std::vector< int > &  indexes,
Record rec 
)

coral::AttributeList& ora::MultiIndexDataTrie::lookup( const std::vector<int>& indexes ){ MultiIndexDataTrie* trie = this; for( size_t i=0;i<indexes.size();i++){ if( trie->m_children.size()==0 || indexes[i] > (int)(trie->m_children.size()-1)){ std::stringstream mess; mess << "Index["<<i<<"] is out of bound."; throwException( mess.str(),"MultiIndexDataTrie::lookup" ); } trie = trie->m_children[indexes[i]]; if( !trie ){ std::stringstream mess; mess << "Slot for index["<<i<<"] is empty."; throwException( mess.str(),"MultiIndexDataTrie::lookup" ); } } if(!trie->m_data.get()){ throwException( "No Data for the specified index combination.", "MultiIndexDataTrie::lookup" ); } return *trie->m_data; }

Definition at line 69 of file MultiIndexDataTrie.cc.

References i, python.Node::leaf, m_children, m_data, ora::Record::size(), ora::Record::swap(), and ora::throwException().

69  {
70  MultiIndexDataTrie* branch = this;
71  MultiIndexDataTrie* trie = 0;
72  size_t i=0;
73  for( ;i<indexes.size();i++){
74  if( branch->m_children.size()==0 || indexes[i] > (int)(branch->m_children.size()-1)){
75  std::stringstream mess;
76  mess << "Index["<<i<<"] is out of bound.";
77  throwException( mess.str(),"MultiIndexDataTrie::lookupAndClear" );
78  }
79  trie = branch;
80  branch = branch->m_children[indexes[i]];
81  if( !branch ){
82  std::stringstream mess;
83  mess << "Slot for index["<<i<<"] is empty.";
84  throwException( mess.str(),"MultiIndexDataTrie::lookupAndClear" );
85  }
86  }
87  if( trie ){
88  MultiIndexDataTrie* leaf = trie->m_children[indexes[i-1]];
89  if(0==leaf->m_data.size()){
90  throwException( "No Data for the specified index combination.",
91  "MultiIndexDataTrie::lookupAndClear" );
92  }
93  rec.swap(leaf->m_data);
94  delete leaf;
95  trie->m_children[indexes[i-1]] = 0;
96  }
97 }
int i
Definition: DBlmapReader.cc:9
tuple leaf
Definition: Node.py:62
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
size_t ora::MultiIndexDataTrie::push ( const std::vector< int > &  indexes,
Record data 
)

Definition at line 18 of file MultiIndexDataTrie.cc.

References i, j, m_children, m_data, nt, alignCSCRings::s, ora::Record::swap(), and ora::throwException().

19  {
20  size_t s=0;
21  MultiIndexDataTrie* trie = this;
22  for( size_t i=0;i<indexes.size();i++){
23  size_t ts = trie->m_children.size();
25  if( ts == 0 || indexes[i] > (int)(ts-1) ){
26  for(size_t j=0;j<indexes[i]-ts+1;j++){
27  ++s;
28  nt = new MultiIndexDataTrie;
29  trie->m_children.push_back(nt);
30  }
31  } else {
32  nt = trie->m_children[indexes[i]];
33  if( !nt ){
34  std::stringstream mess;
35  mess << "Slot for index["<<i<<"] is empty.";
36  throwException( mess.str(),"MultiIndexDataTrie::push" );
37  }
38  }
39  trie = nt;
40  }
41  if( trie ) trie->m_data.swap(data);
42  return s;
43 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
int nt
Definition: AMPTWrapper.h:32
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
size_t ora::MultiIndexDataTrie::size ( void  ) const

Definition at line 99 of file MultiIndexDataTrie.cc.

99  {
100  return m_children.size();
101 }
std::vector< MultiIndexDataTrie * > m_children
size_t ora::MultiIndexDataTrie::totalSize ( ) const

Definition at line 134 of file MultiIndexDataTrie.cc.

134  {
135  size_t sz = 0;
136  for(std::vector<MultiIndexDataTrie*>::const_iterator iT = m_children.begin();
137  iT != m_children.end(); iT++){
138  sz++;
139  if(*iT) sz += (*iT)->totalSize();
140  }
141  return sz;
142 }
std::vector< MultiIndexDataTrie * > m_children

Member Data Documentation

std::vector<MultiIndexDataTrie*> ora::MultiIndexDataTrie::m_children
private

Definition at line 36 of file MultiIndexDataTrie.h.

Referenced by branchSize(), lookupAndClear(), and push().

Record ora::MultiIndexDataTrie::m_data
private

Definition at line 37 of file MultiIndexDataTrie.h.

Referenced by lookupAndClear(), and push().