TRF Language Model
wb::Trie< KeyT, DataT > Class Template Reference

trie structure More...

#include <wb-trie.h>

Public Member Functions

 Trie ()
 
 ~Trie ()
 
void Release ()
 Release all the trie. More...
 
size_t TotalMemCost ()
 Compute the total memory cost of the trie structure. More...
 
void Clean ()
 Clean. More...
 
void Fill (DataT d)
 set all the values to d More...
 
DataT * GetData ()
 Get value. More...
 
_wb_LHASH_FOR_TRIEGetHash () const
 Get hash pointer. More...
 
bool IsDataLegal ()
 detect if current trie have legal value More...
 
DataT * Find (const KeyT *p_pIndex, int nIndexLen, bool &bFound)
 Find a value. More...
 
DataT * Insert (const KeyT *p_pIndex, int nIndexLen, bool &bFound)
 Insert a value. More...
 
_wb_TRIEFindTrie (const KeyT *p_pIndex, int nIndexLen, bool &bFound)
 Find a sub-trie. More...
 
_wb_TRIEInsertTrie (const KeyT *p_pIndex, int nIndexLen, bool &bFound)
 Insert a sub-trie. More...
 
DataT * Find (const KeyT *p_pIndex, int nIndexLen)
 Find a value. More...
 
DataT * Insert (const KeyT *p_pIndex, int nIndexLen)
 Insert a value. More...
 
_wb_TRIEFindTrie (const KeyT *p_pIndex, int nIndexLen)
 Find a sub-trie. More...
 
_wb_TRIEInsertTrie (const KeyT *p_pIndex, int nIndexLen)
 Insert a sub-trie. More...
 

Friends

class TrieIter< KeyT, DataT >
 
class TrieIter2< KeyT, DataT >
 

Detailed Description

template<class KeyT, class DataT>
class wb::Trie< KeyT, DataT >

trie structure

Trie��ʹ����һ����Ҫע������⣺ ��������һ����״�ṹ����ˣ�����߽׵�index�������ͽ׽ڵ㣬�磺����abc��������a��ab�ڵ㣬���ʹ��Find��Insert�����Żص� bFoundΪtrue�����Ⲣ����ζ�����Dz����a��ab�������ȷ���ж��Ƿ����ķ���Ϊ��

DataT *p = trie.Find(index, len);
if ( !p ) {
*trie.Insert(index, len) = %��һ��ֵ%
%û�г���%
} else {
%���%
}

��ΪFind�������жϵ�ǰ�ڵ㴦����ֵ�Ƿ񱻸���ֵ��������ֵ����Ż���ָ�룻���򣬷���NULL

Definition at line 40 of file wb-trie.h.

Constructor & Destructor Documentation

§ Trie()

template<class KeyT, class DataT>
wb::Trie< KeyT, DataT >::Trie ( )
inline

Definition at line 75 of file wb-trie.h.

§ ~Trie()

template<class KeyT, class DataT>
wb::Trie< KeyT, DataT >::~Trie ( )
inline

Definition at line 76 of file wb-trie.h.

Member Function Documentation

§ Clean()

template<class KeyT, class DataT>
void wb::Trie< KeyT, DataT >::Clean ( )
inline

Clean.

Definition at line 113 of file wb-trie.h.

§ Fill()

template<class KeyT, class DataT>
void wb::Trie< KeyT, DataT >::Fill ( DataT  d)
inline

set all the values to d

Definition at line 115 of file wb-trie.h.

§ Find() [1/2]

template<class KeyT, class DataT>
DataT* wb::Trie< KeyT, DataT >::Find ( const KeyT *  p_pIndex,
int  nIndexLen,
bool &  bFound 
)
inline

Find a value.

Definition at line 132 of file wb-trie.h.

§ Find() [2/2]

template<class KeyT, class DataT>
DataT* wb::Trie< KeyT, DataT >::Find ( const KeyT *  p_pIndex,
int  nIndexLen 
)
inline

Find a value.

Definition at line 185 of file wb-trie.h.

§ FindTrie() [1/2]

template<class KeyT, class DataT>
_wb_TRIE* wb::Trie< KeyT, DataT >::FindTrie ( const KeyT *  p_pIndex,
int  nIndexLen,
bool &  bFound 
)
inline

Find a sub-trie.

Definition at line 148 of file wb-trie.h.

§ FindTrie() [2/2]

template<class KeyT, class DataT>
_wb_TRIE* wb::Trie< KeyT, DataT >::FindTrie ( const KeyT *  p_pIndex,
int  nIndexLen 
)
inline

Find a sub-trie.

Definition at line 197 of file wb-trie.h.

§ GetData()

template<class KeyT, class DataT>
DataT* wb::Trie< KeyT, DataT >::GetData ( )
inline

Get value.

Definition at line 126 of file wb-trie.h.

§ GetHash()

template<class KeyT, class DataT>
_wb_LHASH_FOR_TRIE* wb::Trie< KeyT, DataT >::GetHash ( ) const
inline

Get hash pointer.

Definition at line 128 of file wb-trie.h.

§ Insert() [1/2]

template<class KeyT, class DataT>
DataT* wb::Trie< KeyT, DataT >::Insert ( const KeyT *  p_pIndex,
int  nIndexLen,
bool &  bFound 
)
inline

Insert a value.

Definition at line 142 of file wb-trie.h.

§ Insert() [2/2]

template<class KeyT, class DataT>
DataT* wb::Trie< KeyT, DataT >::Insert ( const KeyT *  p_pIndex,
int  nIndexLen 
)
inline

Insert a value.

Definition at line 191 of file wb-trie.h.

§ InsertTrie() [1/2]

template<class KeyT, class DataT>
_wb_TRIE* wb::Trie< KeyT, DataT >::InsertTrie ( const KeyT *  p_pIndex,
int  nIndexLen,
bool &  bFound 
)
inline

Insert a sub-trie.

Definition at line 169 of file wb-trie.h.

§ InsertTrie() [2/2]

template<class KeyT, class DataT>
_wb_TRIE* wb::Trie< KeyT, DataT >::InsertTrie ( const KeyT *  p_pIndex,
int  nIndexLen 
)
inline

Insert a sub-trie.

Definition at line 203 of file wb-trie.h.

§ IsDataLegal()

template<class KeyT, class DataT>
bool wb::Trie< KeyT, DataT >::IsDataLegal ( )
inline

detect if current trie have legal value

Definition at line 130 of file wb-trie.h.

§ Release()

template<class KeyT, class DataT>
void wb::Trie< KeyT, DataT >::Release ( )
inline

Release all the trie.

Definition at line 78 of file wb-trie.h.

§ TotalMemCost()

template<class KeyT, class DataT>
size_t wb::Trie< KeyT, DataT >::TotalMemCost ( )
inline

Compute the total memory cost of the trie structure.

Definition at line 97 of file wb-trie.h.

Friends And Related Function Documentation

§ TrieIter2< KeyT, DataT >

template<class KeyT, class DataT>
friend class TrieIter2< KeyT, DataT >
friend

Definition at line 70 of file wb-trie.h.

§ TrieIter< KeyT, DataT >

template<class KeyT, class DataT>
friend class TrieIter< KeyT, DataT >
friend

Definition at line 69 of file wb-trie.h.


The documentation for this class was generated from the following file: