WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
WXP::Hash Class Reference

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

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

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
Utility

Constructor & Destructor Documentation

◆ Hash() [1/4]

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

Constructor

Parameters
rtypeType of hash table (STRING, BOOL, INT, FLOAT, DATA)
rsizeSize of hash table (entries)
rdata_sizeSize of data to be entered into hash
rnumkeyNumber of keys into table

References init(), and set().

◆ Hash() [2/4]

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

Constructor (STRING)

Parameters
rsizeSize of hash table (entries)
rdata_sizeSize of data to be entered into hash
rnumkeyNumber of keys into table

References init(), and set().

◆ Hash() [3/4]

Hash::Hash ( int  rtype)

Constructor

Parameters
rtypeType of hash table (STRING, BOOL, INT, FLOAT, DATA)

References init(), and set().

◆ Hash() [4/4]

Hash::Hash ( )

Constructor (all defaults)

References init(), and set().

◆ ~Hash()

Hash::~Hash ( )

Destructor

Member Function Documentation

◆ clear()

int Hash::clear ( )

Clears the data in the hash

◆ enter()

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

Enters a new key into hash table

Parameters
key1First key
key2Second key (optional)
key3Third key (optional)
key4Fourth key (optional)
dataData

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

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

◆ first()

int Hash::first ( )

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

Referenced by WXP::CityHash::first(), WXP::MdrHash::first(), and WXP::MdrHash::print().

◆ init()

int Hash::init ( )

Initializes the class, resets values and clears out all data

Referenced by Hash(), Hash(), Hash(), Hash(), WXP::CityHash::init(), and set().

◆ key()

int Hash::key ( const char *  rkey)

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

Parameters
rkeyString to pass to hash function

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

◆ next()

char * Hash::next ( )

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

Returns
The data value

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

◆ nextKey()

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().

◆ print()

int Hash::print ( )

Prints hash table use stats

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

◆ printData()

int Hash::printData ( )

Prints all the data values stored in table.

◆ printHash()

int Hash::printHash ( )

Prints all the data values stored in table.

◆ search() [1/2]

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

Searches the hash for key (first key)

Parameters
rkeyThe key value to search for

References search().

◆ search() [2/2]

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

Searches the hash for data

Parameters
keynumThe key number to use
rkeyThe key value to search for

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

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

◆ searchBool() [1/2]

int Hash::searchBool ( const char *  rkey)

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

Parameters
rkeyThe key value to search for
Returns
Boolean value stored in hash

References searchBool().

◆ searchBool() [2/2]

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

Searches the hash for key. Returns boolean value

Parameters
keynumThe key number to use
rkeyThe key value to search for
Returns
Boolean value stored in hash

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

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

◆ searchFloat() [1/2]

float Hash::searchFloat ( const char *  rkey)

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

Parameters
rkeyThe key value to search for
Returns
Float value stored in hash

References searchFloat().

◆ searchFloat() [2/2]

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

Searches the hash for key. Returns float value

Parameters
keynumThe key number to use
rkeyThe key value to search for
Returns
Float value stored in hash

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

Referenced by searchFloat().

◆ searchInt() [1/2]

int Hash::searchInt ( const char *  rkey)

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

Parameters
rkeyThe key value to search for
Returns
Integer value stored in hash

References searchInt().

◆ searchInt() [2/2]

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

Searches the hash for key. Returns integer value

Parameters
keynumThe key number to use
rkeyThe key value to search for
Returns
Integer value stored in hash

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

Referenced by searchInt().

◆ set() [1/4]

int Hash::set ( )

Sets up the initial type with all defaults

References set().

Referenced by Hash(), Hash(), Hash(), Hash(), set(), set(), and set().

◆ set() [2/4]

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

Sets up the initial table (STRING)

Parameters
rsizeSize of hash table (entries)
rdata_sizeSize of data to be entered into hash
rnumkeyNumber of keys into table

References set().

◆ set() [3/4]

int Hash::set ( int  rtype)

Sets up the initial table

Parameters
rtypeType of hash table (STRING, BOOL, INT, FLOAT, DATA)

References set().

◆ set() [4/4]

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

Sets up the initial table

Parameters
rtypeType of hash table (STRING, BOOL, INT, FLOAT, DATA)
rsizeSize of hash table (entries)
rdata_sizeSize of data to be entered into hash
rnumkeyNumber of keys into table

References init().

Referenced by WXP::MdrHash::init(), WXP::CityHash::setup(), WXP::UpaRawinHash::setup(), and WXP::CityHash::setup().


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