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

a linear hash table More...

#include <wb-lhash.h>

Classes

struct  Unit
 the Unit of hash More...
 

Public Member Functions

 LHash (int nSize=0)
 constructor More...
 
 ~LHash ()
 destructor More...
 
int GetNum () const
 Get the unit number. More...
 
int GetSize () const
 Get the buffer size of hash. More...
 
int GetMaxBits () const
 Get the buffer size bits. More...
 
const UnitGetBuffer () const
 Get the buffer. More...
 
size_t TotalMemCost ()
 Compute the whole memory cost of hash structure. More...
 
int RoundSize (int nSize)
 calculate the buffer size need to be allocated More...
 
void Alloc (int nSize)
 Allocate the buffer. More...
 
void Release ()
 Release the buffer. More...
 
void Reset (int nSize)
 Reset the hash buffer. More...
 
void Clean ()
 Clean the hash, but don't release the buffer. More...
 
void Fill (DataT d)
 Set all the values to d. More...
 
bool Locate (KeyT key, int &index) const
 Find the key. More...
 
DataT * Find (KeyT key, bool &bFound)
 Find a value. More...
 
DataT * Find (KeyT key)
 Find a value. More...
 
DataT * Insert (KeyT key, bool &bFound)
 Insert a value. More...
 
DataT * Insert (KeyT key)
 Insert a value. More...
 
void Copy (LHash< KeyT, DataT > &other)
 Copy hash. More...
 

Protected Attributes

int m_nMaxBits
 The bit number of the memory buffer. (2^m_nMaxBits is the memory size) More...
 
int m_nUnitNum
 The unit number add to the hash. More...
 
Unitm_pUnit
 pointer to the buffer. More...
 

Friends

class LHashIter< KeyT, DataT >
 

Detailed Description

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

a linear hash table

Definition at line 41 of file wb-lhash.h.

Constructor & Destructor Documentation

§ LHash()

template<class KeyT, class DataT>
wb::LHash< KeyT, DataT >::LHash ( int  nSize = 0)
inline

constructor

Definition at line 231 of file wb-lhash.h.

§ ~LHash()

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

destructor

Definition at line 233 of file wb-lhash.h.

Member Function Documentation

§ Alloc()

template<class KeyT, class DataT>
void wb::LHash< KeyT, DataT >::Alloc ( int  nSize)
inline

Allocate the buffer.

Definition at line 255 of file wb-lhash.h.

§ Clean()

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

Clean the hash, but don't release the buffer.

Definition at line 309 of file wb-lhash.h.

§ Copy()

template<class KeyT, class DataT>
void wb::LHash< KeyT, DataT >::Copy ( LHash< KeyT, DataT > &  other)
inline

Copy hash.

Definition at line 467 of file wb-lhash.h.

§ Fill()

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

Set all the values to d.

Definition at line 322 of file wb-lhash.h.

§ Find() [1/2]

template<class KeyT, class DataT>
DataT* wb::LHash< KeyT, DataT >::Find ( KeyT  key,
bool &  bFound 
)
inline

Find a value.

Definition at line 392 of file wb-lhash.h.

§ Find() [2/2]

template<class KeyT, class DataT>
DataT* wb::LHash< KeyT, DataT >::Find ( KeyT  key)
inline

Find a value.

Definition at line 403 of file wb-lhash.h.

§ GetBuffer()

template<class KeyT, class DataT>
const Unit* wb::LHash< KeyT, DataT >::GetBuffer ( ) const
inline

Get the buffer.

Definition at line 241 of file wb-lhash.h.

§ GetMaxBits()

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::GetMaxBits ( ) const
inline

Get the buffer size bits.

Definition at line 239 of file wb-lhash.h.

§ GetNum()

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::GetNum ( ) const
inline

Get the unit number.

Definition at line 235 of file wb-lhash.h.

§ GetSize()

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::GetSize ( ) const
inline

Get the buffer size of hash.

Definition at line 237 of file wb-lhash.h.

§ Insert() [1/2]

template<class KeyT, class DataT>
DataT* wb::LHash< KeyT, DataT >::Insert ( KeyT  key,
bool &  bFound 
)
inline

Insert a value.

Definition at line 408 of file wb-lhash.h.

§ Insert() [2/2]

template<class KeyT, class DataT>
DataT* wb::LHash< KeyT, DataT >::Insert ( KeyT  key)
inline

Insert a value.

Definition at line 461 of file wb-lhash.h.

§ Locate()

template<class KeyT, class DataT>
bool wb::LHash< KeyT, DataT >::Locate ( KeyT  key,
int &  index 
) const
inline

Find the key.

Definition at line 333 of file wb-lhash.h.

§ Release()

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

Release the buffer.

Definition at line 284 of file wb-lhash.h.

§ Reset()

template<class KeyT, class DataT>
void wb::LHash< KeyT, DataT >::Reset ( int  nSize)
inline

Reset the hash buffer.

Definition at line 302 of file wb-lhash.h.

§ RoundSize()

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::RoundSize ( int  nSize)
inline

calculate the buffer size need to be allocated

Definition at line 248 of file wb-lhash.h.

§ TotalMemCost()

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

Compute the whole memory cost of hash structure.

Definition at line 243 of file wb-lhash.h.

Friends And Related Function Documentation

§ LHashIter< KeyT, DataT >

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

Definition at line 211 of file wb-lhash.h.

Member Data Documentation

§ m_nMaxBits

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::m_nMaxBits
protected

The bit number of the memory buffer. (2^m_nMaxBits is the memory size)

Definition at line 220 of file wb-lhash.h.

§ m_nUnitNum

template<class KeyT, class DataT>
int wb::LHash< KeyT, DataT >::m_nUnitNum
protected

The unit number add to the hash.

Definition at line 221 of file wb-lhash.h.

§ m_pUnit

template<class KeyT, class DataT>
Unit* wb::LHash< KeyT, DataT >::m_pUnit
protected

pointer to the buffer.

Definition at line 222 of file wb-lhash.h.


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