WXP::Hash Class Reference

This class creates and manages generic hash tables. More...

#include "../include/Hash.h"

List of all members.

Classes

struct  HashEntry

Public Types

enum  {
  STRING, BOOL, INT, FLOAT,
  DATA
}

Public Member Functions

 Hash (int rtype, int rsize, int rdata_size, int rnumkey)
 Hash (int rsize, int rdata_size, int rnumkey)
 Hash (int rtype)
 Hash ()
 ~Hash ()
int init ()
int set (int rtype, int rsize, int rdata_size, int rnumkey)
int set (int rsize, int rdata_size, int rnumkey)
int set (int rtype)
int set ()
int key (const char *rkey)
int enter (const char *data,...)
char * search (int keynum, const char *key)
char * search (const char *key)
int searchInt (int keynum, const char *rkey)
int searchInt (const char *rkey)
int searchBool (int keynum, const char *rkey)
int searchBool (const char *rkey)
float searchFloat (int keynum, const char *rkey)
float searchFloat (const char *rkey)
int first ()
char * next ()
char * nextKey ()
int clear ()
int getSize ()
int getDataSize ()
int getNumKey ()
int getNum ()
int print ()
int printData ()
int printHash ()

Detailed Description

This class creates and manages generic hash tables.

Author:
Dan Vietor

Constructor & Destructor Documentation

Hash::Hash ( int  rtype,
int  rsize,
int  rdata_size,
int  rnumkey 
)

Constructor

Parameters:
rtype Type of hash table (STRING, BOOL, INT, FLOAT, DATA)
rsize Size of hash table (entries)
rdata_size Size of data to be entered into hash
rnumkey Number of keys into table

References init().

Hash::Hash ( int  rsize,
int  rdata_size,
int  rnumkey 
)

Constructor (STRING)

Parameters:
rsize Size of hash table (entries)
rdata_size Size of data to be entered into hash
rnumkey Number of keys into table

References init().

Hash::Hash ( int  rtype  ) 

Constructor

Parameters:
rtype Type of hash table (STRING, BOOL, INT, FLOAT, DATA)

References init().

Hash::Hash (  ) 

Constructor (all defaults)

References init().

Hash::~Hash (  ) 

Destructor


Member Function Documentation

int Hash::clear (  ) 

Clears the data in the hash

int Hash::enter ( const char *  key1,
  ... 
)

Enters a new key into hash table

Parameters:
key1 First key
key2 Second key (optional)
key3 Third key (optional)
key4 Fourth key (optional)
data Data

References WXP::StrLib::acopy(), WXP::StrLib::equal(), and key().

Referenced by WXP::UpaRawinHash::put(), WXP::SfcHash::put(), WXP::RcmHash::put(), WXP::MdrHash::put(), WXP::CityHash::set(), and WXP::DataMath::uniqueId().

int Hash::first (  ) 

Resets pointer to beginning of list. Use with next and nextKey methods.

Referenced by WXP::CityHash::first().

int Hash::init (  ) 

Initializes the class, resets values and clears out all data

Referenced by Hash(), and set().

int Hash::key ( const char *  rkey  ) 

This function returns the index in the hash table based on the hashing function.

Parameters:
rkey String to pass to hash function

Referenced by enter(), search(), searchBool(), searchFloat(), and searchInt().

char * Hash::next (  ) 

Moves to next key in list. Order based on ordered entered into table.

Returns:
The data value

Referenced by WXP::SfcHash::next(), WXP::RcmHash::next(), and WXP::MdrHash::next().

char * Hash::nextKey (  ) 

Moves to next key in list. Order based on ordered entered into table.

Returns:
The key value

Referenced by WXP::CityHash::nextKey().

int Hash::print (  ) 

Prints hash table use stats

Referenced by WXP::CityHash::print(), and WXP::CityHash::printData().

int Hash::printData (  ) 

Prints all the data values stored in table.

int Hash::printHash (  ) 

Prints all the data values stored in table.

char * Hash::search ( const char *  rkey  ) 

Searches the hash for key (first key)

Parameters:
rkey The key value to search for

References search().

char * Hash::search ( int  keynum,
const char *  rkey 
)

Searches the hash for data

Parameters:
keynum The key number to use
rkey The key value to search for

References WXP::StrLib::equal(), and key().

Referenced by WXP::UpaRawinHash::get(), WXP::SfcHash::get(), WXP::RcmHash::get(), WXP::MdrHash::get(), WXP::CityHash::get(), WXP::UpaRawinHash::put(), and search().

int Hash::searchBool ( const char *  rkey  ) 

Searches the hash for key (first key). Returns boolean value

Parameters:
rkey The key value to search for
Returns:
Boolean value stored in hash

References searchBool().

int Hash::searchBool ( int  keynum,
const char *  rkey 
)

Searches the hash for key. Returns boolean value

Parameters:
keynum The key number to use
rkey The key value to search for
Returns:
Boolean value stored in hash

References WXP::StrLib::equal(), and key().

Referenced by searchBool(), and WXP::DataMath::uniqueId().

float Hash::searchFloat ( const char *  rkey  ) 

Searches the hash for key (first key). Returns float value

Parameters:
rkey The key value to search for
Returns:
Float value stored in hash

References searchFloat().

float Hash::searchFloat ( int  keynum,
const char *  rkey 
)

Searches the hash for key. Returns float value

Parameters:
keynum The key number to use
rkey The key value to search for
Returns:
Float value stored in hash

References WXP::StrLib::equal(), and key().

Referenced by searchFloat().

int Hash::searchInt ( const char *  rkey  ) 

Searches the hash for key (first key). Returns integer value

Parameters:
rkey The key value to search for
Returns:
Integer value stored in hash

References searchInt().

int Hash::searchInt ( int  keynum,
const char *  rkey 
)

Searches the hash for key. Returns integer value

Parameters:
keynum The key number to use
rkey The key value to search for
Returns:
Integer value stored in hash

References WXP::StrLib::equal(), key(), and WXP::Const::MISS.

Referenced by searchInt().

int Hash::set (  ) 

Sets up the initial type with all defaults

int Hash::set ( int  rtype  ) 

Sets up the initial table

Parameters:
rtype Type of hash table (STRING, BOOL, INT, FLOAT, DATA)
int Hash::set ( int  rsize,
int  rdata_size,
int  rnumkey 
)

Sets up the initial table (STRING)

Parameters:
rsize Size of hash table (entries)
rdata_size Size of data to be entered into hash
rnumkey Number of keys into table
int Hash::set ( int  rtype,
int  rsize,
int  rdata_size,
int  rnumkey 
)

Sets up the initial table

Parameters:
rtype Type of hash table (STRING, BOOL, INT, FLOAT, DATA)
rsize Size of hash table (entries)
rdata_size Size of data to be entered into hash
rnumkey Number of keys into table

References init().

Referenced by WXP::CityHash::set().


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

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1