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.

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 110 of file MultiIndexDataTrie.cc.

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

110  {
111  if( depth > indexes.size() ) depth = indexes.size();
112  const MultiIndexDataTrie* trie = this;
113  for( size_t i=0;i<depth;i++){
114  if( trie->m_children.size()==0 || indexes[i] > (int)(trie->m_children.size()-1)){
115  std::stringstream mess;
116  mess << "Index["<<i<<"] is out of bound.";
117  throwException( mess.str(),"MultiIndexDataTrie::lookup" );
118  }
119  trie = trie->m_children[indexes[i]];
120  if( !trie ){
121  std::stringstream mess;
122  mess << "Slot for index["<<i<<"] is empty.";
123  throwException( mess.str(),"MultiIndexDataTrie::branchSize" );
124  }
125  }
126  return trie->m_children.size();
127 }
int i
Definition: DBlmapReader.cc:9
void throwException(const std::string &message, const std::string &methodName)
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::lookup" );
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  MultiIndexDataTrie* leaf = trie->m_children[indexes[i-1]];
88  if(0==leaf->m_data.size()){
89  throwException( "No Data for the specified index combination.",
90  "MultiIndexDataTrie::lookupAndClear" );
91  }
92  rec.swap(leaf->m_data);
93  delete leaf;
94  trie->m_children[indexes[i-1]] = 0;
95 }
int i
Definition: DBlmapReader.cc:9
tuple leaf
Definition: Node.py:62
void throwException(const std::string &message, const std::string &methodName)
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, asciidump::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  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)
Definition: Exception.cc:10
string s
Definition: asciidump.py:422
size_t ora::MultiIndexDataTrie::size ( void  ) const

Definition at line 97 of file MultiIndexDataTrie.cc.

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

Definition at line 129 of file MultiIndexDataTrie.cc.

129  {
130  size_t sz = 0;
131  for(std::vector<MultiIndexDataTrie*>::const_iterator iT = m_children.begin();
132  iT != m_children.end(); iT++){
133  sz++;
134  if(*iT) sz += (*iT)->totalSize();
135  }
136  return sz;
137 }
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().