CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::TrieNode< T > Class Template Reference

this class represent the node of a trie, it contains a link to a sub node and a link to a brother (node which have the same father) More...

#include <Trie.h>

Public Types

typedef TrieNodeIter< Tconst_iterator
 

Public Member Functions

void addSubNode (unsigned char chr, TrieNode< T > *node)
 
TrieNodeIter< Tbegin () const
 initialize subnode iterator (std conforming) More...
 
const TrieNode< T > * brother () const
 get brother (return 0x0 this node has no brother) More...
 
TrieNode< T > * brother ()
 
unsigned char brotherLabel () const
 get brother label More...
 
void clear ()
 clear content of TrieNode More...
 
void display (std::ostream &os, unsigned offset, unsigned char label) const
 display content of node in output stream More...
 
TrieNodeIter< Tend () const
 mark end of iteration (std conforming) More...
 
void setValue (const T &val)
 set value associed to node More...
 
const TrieNode< T > * subNode () const
 
TrieNode< T > * subNode ()
 
const TrieNode< T > * subNodeByLabel (unsigned char chr) const
 
TrieNode< T > * subNodeByLabel (unsigned char chr)
 
unsigned char subNodeLabel () const
 
 TrieNode ()
 
const Tvalue () const
 get value associed to node More...
 
 ~TrieNode ()
 

Private Member Functions

void _addBrother (unsigned char chr, TrieNode< T > *brother)
 add a new brother More...
 
const TrieNode< T > * _getBrother (unsigned char chr) const
 
TrieNode< T > * _getBrother (unsigned char chr)
 
template<typename Node >
Node _sequentialSearch (Node first, unsigned char label, unsigned char val) const
 
void _setBrother (TrieNode< T > *brother, unsigned char brotherLabel)
 set brother (used by sort) More...
 
TrieNodeoperator= (const TrieNode &e)
 avoid affectation operator More...
 
 TrieNode (const TrieNode &e)
 avoid copy constructor More...
 

Private Attributes

TrieNode< T > * _brother
 pointer to brother (node with same father as this one) More...
 
unsigned char _brotherLabel
 character to go to brother (node with same father as this one) More...
 
TrieNode< T > * _firstSubNode
 pointer to first sub node More...
 
unsigned char _firstSubNodeLabel
 character to go to first subnode More...
 
T _value
 value associed to this node More...
 

Detailed Description

template<typename T>
class edm::TrieNode< T >

this class represent the node of a trie, it contains a link to a sub node and a link to a brother (node which have the same father)

Definition at line 34 of file Trie.h.

Member Typedef Documentation

template<typename T>
typedef TrieNodeIter<T> edm::TrieNode< T >::const_iterator

Definition at line 84 of file Trie.h.

Constructor & Destructor Documentation

template<typename T >
edm::TrieNode< T >::TrieNode ( )

we can not set _value here because type is unknown. assert that the value is set later with setValue()

Definition at line 364 of file Trie.h.

364  :
368 {
369 }
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
T _value
value associed to this node
Definition: Trie.h:160
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
edm::TrieNode< T >::~TrieNode ( )

Definition at line 372 of file Trie.h.

373 {
374  // do not delete _brother and _firstSubNode because they are
375  // allocated by factory (TrieFactory) and factory will delete them
376 }
template<typename T>
edm::TrieNode< T >::TrieNode ( const TrieNode< T > &  e)
private

avoid copy constructor

Member Function Documentation

template<typename T >
void edm::TrieNode< T >::_addBrother ( unsigned char  chr,
TrieNode< T > *  brother 
)
private

add a new brother

Definition at line 428 of file Trie.h.

References edm::TrieNode< T >::_addBrother(), and edm::TrieNode< T >::_setBrother().

Referenced by edm::TrieNode< T >::_addBrother().

429 {
430  if (!_brother || _brotherLabel > chr)
431  {
432  brother->_setBrother(_brother, _brotherLabel);
433  _brother = brother;
434  _brotherLabel = chr;
435  }
436  else
437  _brother->_addBrother(chr, brother);
438 }
const TrieNode< T > * brother() const
get brother (return 0x0 this node has no brother)
Definition: Trie.h:403
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::_getBrother ( unsigned char  chr) const
private

@ brief get brother that has the label chr (return 0x0 if brother is not found)

Definition at line 415 of file Trie.h.

416 {
417  const TrieNode<T> *brother = _brother;
418  return _sequentialSearch(brother, _brotherLabel, chr);
419 }
const TrieNode< T > * brother() const
get brother (return 0x0 this node has no brother)
Definition: Trie.h:403
Node _sequentialSearch(Node first, unsigned char label, unsigned char val) const
Definition: Trie.h:492
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
edm::TrieNode< T > * edm::TrieNode< T >::_getBrother ( unsigned char  chr)
private

@ brief get brother that has the label chr (return 0x0 if brother is not found)

Definition at line 422 of file Trie.h.

423 {
425 }
Node _sequentialSearch(Node first, unsigned char label, unsigned char val) const
Definition: Trie.h:492
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
template<typename Node >
Node edm::TrieNode< T >::_sequentialSearch ( Node  first,
unsigned char  label,
unsigned char  val 
) const
inlineprivate

Definition at line 492 of file Trie.h.

References edm::first().

493 {
494  if (first && label <= val)
495  {
496  if (label == val)
497  return first;
498  return first->_getBrother(val);
499  }
500  return 0x0;
501 }
T first(std::pair< T, U > const &p)
template<typename T >
void edm::TrieNode< T >::_setBrother ( TrieNode< T > *  brother,
unsigned char  brotherLabel 
)
private

set brother (used by sort)

Definition at line 504 of file Trie.h.

Referenced by edm::TrieNode< T >::_addBrother(), and edm::TrieNode< T >::addSubNode().

505 {
506  _brother = brother;
508 }
const TrieNode< T > * brother() const
get brother (return 0x0 this node has no brother)
Definition: Trie.h:403
unsigned char brotherLabel() const
get brother label
Definition: Trie.h:441
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
void edm::TrieNode< T >::addSubNode ( unsigned char  chr,
TrieNode< T > *  node 
)

Definition at line 478 of file Trie.h.

References edm::TrieNode< T >::_setBrother(), and python.Node::node.

Referenced by edm::Trie< T >::_addEntry().

479 {
480  if (!_firstSubNode || _firstSubNodeLabel > chr)
481  {
482  node->_setBrother(_firstSubNode, _firstSubNodeLabel);
484  _firstSubNodeLabel = chr;
485  }
486  else
487  _firstSubNode->_addBrother(chr, node);
488 }
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
tuple node
Definition: Node.py:50
template<typename T >
edm::TrieNodeIter< T > edm::TrieNode< T >::begin ( void  ) const

initialize subnode iterator (std conforming)

Definition at line 381 of file Trie.h.

381  {
382  return const_iterator(this);
383 }
TrieNodeIter< T > const_iterator
Definition: Trie.h:84
template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::brother ( ) const

get brother (return 0x0 this node has no brother)

Definition at line 403 of file Trie.h.

Referenced by edm::TrieNodeIter< T >::increment().

404 {
405  return _brother;
406 }
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
edm::TrieNode< T > * edm::TrieNode< T >::brother ( )

Definition at line 409 of file Trie.h.

410 {
411  return _brother;
412 }
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
unsigned char edm::TrieNode< T >::brotherLabel ( ) const

get brother label

Definition at line 441 of file Trie.h.

Referenced by edm::TrieNodeIter< T >::increment().

442 {
443  return _brotherLabel;
444 }
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
template<typename T >
void edm::TrieNode< T >::clear ( void  )
template<typename T >
void edm::TrieNode< T >::display ( std::ostream &  os,
unsigned  offset,
unsigned char  label 
) const

display content of node in output stream

Definition at line 511 of file Trie.h.

References i, and HLT_25ns14e33_v1_cff::offset.

512 {
513  unsigned int i;
514  for (i = 0; i < offset; ++i)
515  os << " ";
516  if (label)
517  os << "label[" << label << "] ";
518  os << "value[" << _value << "]" << std::endl;
519  if (_firstSubNode)
520  _firstSubNode->display(os, offset + 2, _firstSubNodeLabel);
521  if (_brother)
522  _brother->display(os, offset, _brotherLabel);
523 }
int i
Definition: DBlmapReader.cc:9
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
T _value
value associed to this node
Definition: Trie.h:160
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:154
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:152
template<typename T >
edm::TrieNodeIter< T > edm::TrieNode< T >::end ( void  ) const

mark end of iteration (std conforming)

Definition at line 386 of file Trie.h.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

386  {
387  return const_iterator(0);
388 }
TrieNodeIter< T > const_iterator
Definition: Trie.h:84
template<typename T>
TrieNode& edm::TrieNode< T >::operator= ( const TrieNode< T > &  e)
private

avoid affectation operator

template<typename T >
void edm::TrieNode< T >::setValue ( const T val)
template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::subNode ( ) const

Definition at line 447 of file Trie.h.

448 {
449  return _firstSubNode;
450 }
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
template<typename T >
edm::TrieNode< T > * edm::TrieNode< T >::subNode ( )

Definition at line 453 of file Trie.h.

454 {
455  return _firstSubNode;
456 }
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::subNodeByLabel ( unsigned char  chr) const

Definition at line 465 of file Trie.h.

References edm::first().

Referenced by edm::Trie< T >::_addEntry(), edm::Trie< T >::find(), and edm::Trie< T >::node().

466 {
467  const TrieNode<T> *first = _firstSubNode;
468  return _sequentialSearch(first, _firstSubNodeLabel, chr);
469 }
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
Node _sequentialSearch(Node first, unsigned char label, unsigned char val) const
Definition: Trie.h:492
T first(std::pair< T, U > const &p)
template<typename T >
edm::TrieNode< T > * edm::TrieNode< T >::subNodeByLabel ( unsigned char  chr)

Definition at line 472 of file Trie.h.

473 {
475 }
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:156
Node _sequentialSearch(Node first, unsigned char label, unsigned char val) const
Definition: Trie.h:492
template<typename T >
unsigned char edm::TrieNode< T >::subNodeLabel ( ) const

Definition at line 459 of file Trie.h.

460 {
461  return _firstSubNodeLabel;
462 }
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:158
template<typename T >
const T & edm::TrieNode< T >::value ( ) const

Member Data Documentation

template<typename T>
TrieNode<T>* edm::TrieNode< T >::_brother
private

pointer to brother (node with same father as this one)

Definition at line 152 of file Trie.h.

template<typename T>
unsigned char edm::TrieNode< T >::_brotherLabel
private

character to go to brother (node with same father as this one)

Definition at line 154 of file Trie.h.

template<typename T>
TrieNode<T>* edm::TrieNode< T >::_firstSubNode
private

pointer to first sub node

Definition at line 156 of file Trie.h.

template<typename T>
unsigned char edm::TrieNode< T >::_firstSubNodeLabel
private

character to go to first subnode

Definition at line 158 of file Trie.h.

template<typename T>
T edm::TrieNode< T >::_value
private