htable< T > Class Template Reference

T is the type of the key and should be (int*) or (char*). More...

#include <htable.h>

Inheritance diagram for htable< T >:

Inheritance graph
[legend]
Collaboration diagram for htable< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 htable (int n, int kl=0)
 Creates an hash table.
 ~htable ()
 Destroys an and hash table.
void set_keylen (int kl)
address Hash (const T key)
 Computes the hash function.
int Comp (const T Key1, const T Key2)
 Compares the keys of two entries.
T find (T item)
 Searches for an item.
T insert (T item)
T scan (HT_ACTION action)
 Scans the content.
void stat ()
 Prints statistics.
void map (std::ostream &co=std::cout, int cols=80)
 Print a map of memory use.
int used ()
 Returns amount of used memory.
template<>
void set_keylen (int kl)
template<>
address Hash (char *key)
template<>
int Comp (char *key1, char *key2)


Detailed Description

template<class T>
class htable< T >

T is the type of the key and should be (int*) or (char*).

Definition at line 57 of file htable.h.


Constructor & Destructor Documentation

template<class T >
htable< T >::htable ( int  n,
int  kl = 0 
) [inline]

Creates an hash table.

Definition at line 110 of file htable.h.

References BlockSize, and htable< T >::set_keylen().

Here is the call graph for this function:

template<class T >
htable< T >::~htable (  )  [inline]

Destroys an and hash table.

Definition at line 125 of file htable.h.


Member Function Documentation

template<>
int htable< char * >::Comp ( char *  key1,
char *  key2 
) [inline]

Definition at line 97 of file htable.cpp.

template<class T>
int htable< T >::Comp ( const T  Key1,
const T  Key2 
)

Compares the keys of two entries.

Referenced by htable< T >::find(), and htable< T >::insert().

Here is the caller graph for this function:

template<class T>
T htable< T >::find ( T  item  )  [inline]

Searches for an item.

Definition at line 132 of file htable.h.

References htable< T >::Comp(), htable< T >::Hash(), entry< T >::key, entry< T >::next, and NULL.

Referenced by dictionary::encode(), ngramcache::get(), and dictionary::getcode().

Here is the call graph for this function:

Here is the caller graph for this function:

template<>
address htable< char * >::Hash ( char *  key  )  [inline]

Definition at line 68 of file htable.cpp.

References Prime1, and Prime2.

template<class T>
address htable< T >::Hash ( const T  key  ) 

Computes the hash function.

Referenced by htable< T >::find(), and htable< T >::insert().

Here is the caller graph for this function:

template<class T>
T htable< T >::insert ( T  item  )  [inline]

Definition at line 158 of file htable.h.

References mempool::allocate(), htable< T >::Comp(), htable< T >::Hash(), entry< T >::key, entry< T >::next, and NULL.

Referenced by ngramcache::add(), dictionary::dictionary(), dictionary::encode(), dictionary::grow(), dictionary::load(), and dictionary::sort().

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
void htable< T >::map ( std::ostream &  co = std::cout,
int  cols = 80 
)

Print a map of memory use.

template<class T >
T htable< T >::scan ( HT_ACTION  action  )  [inline]

Scans the content.

Definition at line 196 of file htable.h.

References HT_INIT, k, NULL, and T.

Referenced by dictionary::scan().

Here is the caller graph for this function:

template<>
void htable< char * >::set_keylen ( int  kl  )  [inline]

Definition at line 41 of file htable.cpp.

template<class T>
void htable< T >::set_keylen ( int  kl  ) 

Referenced by htable< T >::htable().

Here is the caller graph for this function:

template<class T >
void htable< T >::stat (  )  [inline]

Prints statistics.

Definition at line 258 of file htable.h.

References htable< T >::used().

Here is the call graph for this function:

template<class T>
int htable< T >::used (  )  [inline]

Returns amount of used memory.

Definition at line 101 of file htable.h.

Referenced by ngramcache::stat(), htable< T >::stat(), and dictionary::stat().

Here is the caller graph for this function:


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

Generated on Thu Jul 6 00:31:47 2017 for Moses by  doxygen 1.5.9