CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

edm::TrieFactory< T > Class Template Reference

#include <Trie.h>

List of all members.

Public Member Functions

void clear ()
TrieNode< T > * newNode (const T &value)
 TrieFactory (unsigned paquetSize)
 ~TrieFactory ()

Private Member Functions

TrieFactoryoperator= (const TrieFactory &e)
 avoid affectation operator
 TrieFactory ()
 avoid default constructor
 TrieFactory (const TrieFactory &e)
 avoid copy constructor

Private Attributes

std::list< TrieNode< T > * > _allocatedNodes
TrieNode< T > * _lastNodes
unsigned _nbUsedInLastNodes
unsigned _paquetSize

Detailed Description

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

The goal of this class is to allocate Trie node by paquet of X element in order to reduce heap-admin size

Definition at line 41 of file Trie.h.


Constructor & Destructor Documentation

template<typename T >
edm::TrieFactory< T >::TrieFactory ( unsigned  paquetSize)

Definition at line 321 of file Trie.h.

References edm::TrieFactory< T >::_lastNodes.

                                                  :
  _paquetSize(paquetSize), _lastNodes(0x0), _nbUsedInLastNodes(0)
{
  _lastNodes = new TrieNode<T>[paquetSize];
}
template<typename T >
edm::TrieFactory< T >::~TrieFactory ( )

Definition at line 328 of file Trie.h.

{
  typename std::list<TrieNode<T>*>::const_iterator it;

  for (it = _allocatedNodes.begin(); it != _allocatedNodes.end(); ++it)
    delete[] *it;
  if (_lastNodes)
    delete[] _lastNodes;
}
template<typename T>
edm::TrieFactory< T >::TrieFactory ( ) [private]

avoid default constructor

template<typename T>
edm::TrieFactory< T >::TrieFactory ( const TrieFactory< T > &  e) [private]

avoid copy constructor


Member Function Documentation

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

Definition at line 355 of file Trie.h.

References edm::TrieFactory< T >::clear().

Referenced by edm::TrieFactory< T >::clear().

{
  typename std::list<TrieNode<T>*>::const_iterator it;
  for (it = _allocatedNodes.begin(); it != _allocatedNodes.end(); ++it)
    delete[] *it;
  _allocatedNodes.clear();
  _nbUsedInLastNodes = 0;
}
template<typename T >
edm::TrieNode< T > * edm::TrieFactory< T >::newNode ( const T value)

Definition at line 339 of file Trie.h.

References edm::TrieNode< T >::clear(), and edm::TrieNode< T >::setValue().

{
  if (_nbUsedInLastNodes == _paquetSize)
    {
      _allocatedNodes.push_back(_lastNodes);
      _nbUsedInLastNodes = 0;
      _lastNodes = new TrieNode<T>[_paquetSize];
    }
  TrieNode<T> *res = &_lastNodes[_nbUsedInLastNodes];
  ++_nbUsedInLastNodes;
  res->setValue(value);
  res->clear();
  return res;
}
template<typename T>
TrieFactory& edm::TrieFactory< T >::operator= ( const TrieFactory< T > &  e) [private]

avoid affectation operator


Member Data Documentation

template<typename T>
std::list<TrieNode<T>*> edm::TrieFactory< T >::_allocatedNodes [private]

Definition at line 61 of file Trie.h.

template<typename T>
TrieNode<T>* edm::TrieFactory< T >::_lastNodes [private]

Definition at line 62 of file Trie.h.

Referenced by edm::TrieFactory< T >::TrieFactory().

template<typename T>
unsigned edm::TrieFactory< T >::_nbUsedInLastNodes [private]

Definition at line 63 of file Trie.h.

template<typename T>
unsigned edm::TrieFactory< T >::_paquetSize [private]

Definition at line 60 of file Trie.h.