htable Class Reference

Hash Table for strings. More...

#include <htable.h>

Collaboration diagram for htable:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 htable (int n, int kl=0, HTYPE ht=STRPTR, size_t(*klf)(const char *)=NULL)
 Creates an hash table.
 ~htable ()
 Destroys an and hash table.
address Hash (char *key)
 Computes the hash function.
address HashInt (char *key)
address HashStr (char *key)
int Comp (char *Key1, char *Key2)
 Compares the keys of two entries.
int CompInt (char *Key1, char *Key2)
int CompStr (char *Key1, char *Key2)
char * search (char *item, HT_ACTION action)
 Searches for an item.
char * 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.


Detailed Description

Hash Table for strings.

Definition at line 58 of file htable.h.


Constructor & Destructor Documentation

htable::htable ( int  n,
int  kl = 0,
HTYPE  ht = STRPTR,
size_t(*)(const char *)  klf = NULL 
)

Creates an hash table.

Definition at line 38 of file htable.cpp.

References BlockSize, INT, INTPTR, STR, and STRPTR.

htable::~htable (  ) 

Destroys an and hash table.

Definition at line 197 of file htable.cpp.


Member Function Documentation

int htable::Comp ( char *  Key1,
char *  Key2 
) [inline]

Compares the keys of two entries.

Definition at line 97 of file htable.h.

References CompInt(), CompStr(), INT, INTPTR, STR, and STRPTR.

Referenced by search().

Here is the call graph for this function:

Here is the caller graph for this function:

int htable::CompInt ( char *  Key1,
char *  Key2 
)

Definition at line 290 of file htable.cpp.

References INTPTR.

Referenced by Comp().

Here is the caller graph for this function:

int htable::CompStr ( char *  Key1,
char *  Key2 
)

Definition at line 269 of file htable.cpp.

References STRPTR.

Referenced by Comp().

Here is the caller graph for this function:

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

Computes the hash function.

Definition at line 85 of file htable.h.

References HashInt(), HashStr(), INT, INTPTR, STR, and STRPTR.

Referenced by search().

Here is the call graph for this function:

Here is the caller graph for this function:

address htable::HashInt ( char *  key  ) 

Definition at line 247 of file htable.cpp.

References INTPTR.

Referenced by Hash().

Here is the caller graph for this function:

address htable::HashStr ( char *  key  ) 

Definition at line 203 of file htable.cpp.

References Prime1, Prime2, and STRPTR.

Referenced by Hash().

Here is the caller graph for this function:

void htable::map ( std::ostream &  co = std::cout,
int  cols = 80 
)

Print a map of memory use.

char * htable::scan ( HT_ACTION  action  ) 

Scans the content.

Definition at line 128 of file htable.cpp.

References HT_INIT, k, ENTRY::key, ENTRY::next, and NULL.

Referenced by dictionary_iter::dictionary_iter(), and dictionary_iter::next().

Here is the caller graph for this function:

char * htable::search ( char *  item,
HT_ACTION  action 
)

Searches for an item.

Definition at line 62 of file htable.cpp.

References mempool::allocate(), Comp(), Hash(), HT_FIND, ENTRY::key, ENTRY::next, and NULL.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void htable::stat (  ) 

Prints statistics.

Definition at line 188 of file htable.cpp.

References used().

Here is the call graph for this function:

int htable::used (  )  [inline]

Returns amount of used memory.

Definition at line 122 of file htable.h.

References mempool::used().

Referenced by stat(), and dictionary::stat().

Here is the call graph for this function:

Here is the caller graph for this function:


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

Generated on Fri Apr 15 13:04:15 2011 for Moses by  doxygen 1.5.9