CMS 3D CMS Logo

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...
 
TrieNode< T > * brother ()
 
const TrieNode< T > * brother () const
 get brother (return 0x0 this node has no brother) More...
 
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...
 
TrieNode< T > * subNode ()
 
const TrieNode< T > * subNode () const
 
TrieNode< T > * subNodeByLabel (unsigned char chr)
 
const TrieNode< T > * subNodeByLabel (unsigned char chr) const
 
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...
 
TrieNode< T > * _getBrother (unsigned char chr)
 
const TrieNode< T > * _getBrother (unsigned char chr) const
 
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)=delete
 avoid affectation operator More...
 
 TrieNode (const TrieNode &e)=delete
 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 32 of file Trie.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 76 of file Trie.h.

Constructor & Destructor Documentation

◆ TrieNode() [1/2]

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 327 of file Trie.h.

328  : _brother(nullptr),
329  _brotherLabel(0),
330  _firstSubNode(nullptr),
332  _value()
335 {}

◆ ~TrieNode()

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

Definition at line 338 of file Trie.h.

338  {
339  // do not delete _brother and _firstSubNode because they are
340  // allocated by factory (TrieFactory) and factory will delete them
341 }

◆ TrieNode() [2/2]

template<typename T>
edm::TrieNode< T >::TrieNode ( const TrieNode< T > &  e)
privatedelete

avoid copy constructor

Member Function Documentation

◆ _addBrother()

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

add a new brother

Definition at line 384 of file Trie.h.

384  {
385  if (!_brother || _brotherLabel > chr) {
386  brother->_setBrother(_brother, _brotherLabel);
387  _brother = brother;
388  _brotherLabel = chr;
389  } else
390  _brother->_addBrother(chr, brother);
391 }

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

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

◆ _getBrother() [1/2]

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 379 of file Trie.h.

379  {
381 }

◆ _getBrother() [2/2]

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 373 of file Trie.h.

373  {
374  const TrieNode<T> *brother = _brother;
376 }

◆ _sequentialSearch()

template<typename T >
template<typename Node >
Node edm::TrieNode< T >::_sequentialSearch ( Node  first,
unsigned char  label,
unsigned char  val 
) const
inlineprivate

Definition at line 436 of file Trie.h.

436  {
437  if (first && label <= val) {
438  if (label == val)
439  return first;
440  return first->_getBrother(val);
441  }
442  return 0x0;
443 }

References edm::first(), label, and heppy_batch::val.

◆ _setBrother()

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

set brother (used by sort)

Definition at line 446 of file Trie.h.

446  {
447  _brother = brother;
449 }

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

◆ addSubNode()

template<typename T >
void edm::TrieNode< T >::addSubNode ( unsigned char  chr,
TrieNode< T > *  node 
)

Definition at line 425 of file Trie.h.

425  {
426  if (!_firstSubNode || _firstSubNodeLabel > chr) {
427  node->_setBrother(_firstSubNode, _firstSubNodeLabel);
428  _firstSubNode = node;
429  _firstSubNodeLabel = chr;
430  } else
431  _firstSubNode->_addBrother(chr, node);
432 }

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

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

◆ begin()

template<typename T >
edm::TrieNodeIter< T > edm::TrieNode< T >::begin ( void  ) const

initialize subnode iterator (std conforming)

Definition at line 344 of file Trie.h.

344  {
345  return const_iterator(this);
346 }

◆ brother() [1/2]

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

Definition at line 368 of file Trie.h.

368  {
369  return _brother;
370 }

◆ brother() [2/2]

template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::brother ( ) const

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

Definition at line 363 of file Trie.h.

363  {
364  return _brother;
365 }

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

◆ brotherLabel()

template<typename T >
unsigned char edm::TrieNode< T >::brotherLabel ( ) const

get brother label

Definition at line 394 of file Trie.h.

394  {
395  return _brotherLabel;
396 }

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

◆ clear()

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

clear content of TrieNode

Definition at line 466 of file Trie.h.

466  {
467  _brother = nullptr;
468  _brotherLabel = 0;
469  _firstSubNode = nullptr;
470  _firstSubNodeLabel = 0;
471 }

Referenced by BeautifulSoup.Tag::setString().

◆ display()

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 452 of file Trie.h.

452  {
453  unsigned int i;
454  for (i = 0; i < offset; ++i)
455  os << " ";
456  if (label)
457  os << "label[" << label << "] ";
458  os << "value[" << _value << "]" << std::endl;
459  if (_firstSubNode)
460  _firstSubNode->display(os, offset + 2, _firstSubNodeLabel);
461  if (_brother)
462  _brother->display(os, offset, _brotherLabel);
463 }

References mps_fire::i, label, and hltrates_dqm_sourceclient-live_cfg::offset.

◆ end()

template<typename T >
edm::TrieNodeIter< T > edm::TrieNode< T >::end ( void  ) const

mark end of iteration (std conforming)

Definition at line 348 of file Trie.h.

348  {
349  return const_iterator(nullptr);
350 }

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

◆ operator=()

template<typename T>
TrieNode& edm::TrieNode< T >::operator= ( const TrieNode< T > &  e)
privatedelete

avoid affectation operator

◆ setValue()

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

set value associed to node

Definition at line 353 of file Trie.h.

353  {
354  _value = val;
355 }

References heppy_batch::val.

Referenced by edm::Trie< T >::insert(), and edm::Trie< T >::setEntry().

◆ subNode() [1/2]

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

Definition at line 404 of file Trie.h.

404  {
405  return _firstSubNode;
406 }

◆ subNode() [2/2]

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

Definition at line 399 of file Trie.h.

399  {
400  return _firstSubNode;
401 }

◆ subNodeByLabel() [1/2]

template<typename T >
edm::TrieNode< T > * edm::TrieNode< T >::subNodeByLabel ( unsigned char  chr)

Definition at line 420 of file Trie.h.

420  {
422 }

◆ subNodeByLabel() [2/2]

template<typename T >
const edm::TrieNode< T > * edm::TrieNode< T >::subNodeByLabel ( unsigned char  chr) const

Definition at line 414 of file Trie.h.

414  {
415  const TrieNode<T> *first = _firstSubNode;
417 }

References edm::first().

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

◆ subNodeLabel()

template<typename T >
unsigned char edm::TrieNode< T >::subNodeLabel ( ) const

Definition at line 409 of file Trie.h.

409  {
410  return _firstSubNodeLabel;
411 }

◆ value()

template<typename T >
const T & edm::TrieNode< T >::value ( ) const

Member Data Documentation

◆ _brother

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

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

Definition at line 142 of file Trie.h.

◆ _brotherLabel

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 144 of file Trie.h.

◆ _firstSubNode

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

pointer to first sub node

Definition at line 146 of file Trie.h.

◆ _firstSubNodeLabel

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

character to go to first subnode

Definition at line 148 of file Trie.h.

◆ _value

template<typename T>
T edm::TrieNode< T >::_value
private
mps_fire.i
i
Definition: mps_fire.py:355
edm::TrieNode::_sequentialSearch
Node _sequentialSearch(Node first, unsigned char label, unsigned char val) const
Definition: Trie.h:436
edm::TrieNode::brotherLabel
unsigned char brotherLabel() const
get brother label
Definition: Trie.h:394
edm::TrieNode::const_iterator
TrieNodeIter< T > const_iterator
Definition: Trie.h:76
edm::TrieNode::_brother
TrieNode< T > * _brother
pointer to brother (node with same father as this one)
Definition: Trie.h:142
edm::TrieNode::_brotherLabel
unsigned char _brotherLabel
character to go to brother (node with same father as this one)
Definition: Trie.h:144
edm::first
T first(std::pair< T, U > const &p)
Definition: ParameterSet.cc:210
edm::TrieNode::_firstSubNodeLabel
unsigned char _firstSubNodeLabel
character to go to first subnode
Definition: Trie.h:148
edm::TrieNode::brother
const TrieNode< T > * brother() const
get brother (return 0x0 this node has no brother)
Definition: Trie.h:363
edm::TrieNode::_firstSubNode
TrieNode< T > * _firstSubNode
pointer to first sub node
Definition: Trie.h:146
heppy_batch.val
val
Definition: heppy_batch.py:351
edm::TrieNode::_value
T _value
value associed to this node
Definition: Trie.h:150
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
label
const char * label
Definition: PFTauDecayModeTools.cc:11