HashTable< Key, Data > Class Template Reference

A simple HashTable. More...

#include <hashtable.h>

List of all members.

Public Member Functions

 HashTable (size_t _initialSize=25)
 The constructor.
bool insert (Key const &_key, Data const &_data)
 Inserts data into the table.
bool find (Key const &_key, Data &_data) const
 Finds a node in the table and copies the data from that node to a specified location.
Data find (Key const &_key) const
 Finds a node in the table and returns the data at that node.
bool erase (Key const &_key)
 Deletes a node from the table, specified by the node's key.
bool exists (Key const &_key) const
 Tests whether a key is in the table or not.
size_t size () const
 Indicates the number of subtrees.
size_t used () const
 Indicates the number of items in the table.
size_t mem_usage () const
 Returns the overhead caused by the data structure.

Private Member Functions

 HashTable (const HashTable< Key, Data > &)
 Private copy constructor.
HashTable< Key, Data > & operator= (const HashTable< Key, Data > &)
 Private assignment operator.


Detailed Description

template<class Key, class Data>
class CrissCross::Data::HashTable< Key, Data >

A simple HashTable.

Constructor & Destructor Documentation

HashTable ( const HashTable< Key, Data > &   )  [private]

Private copy constructor.

Not yet written, so declared private for now to prevent an auto-generated one from performing an unexpected operation.

HashTable ( size_t  _initialSize = 25  ) 

The constructor.

Parameters:
_initialSize The initial size of the hash table. Minimum is 500.


Member Function Documentation

bool erase ( Key const &  _key  ) 

Deletes a node from the table, specified by the node's key.

Warning:
This won't free the memory occupied by the data, so the data must be freed separately.
Parameters:
_key The key of the node to delete.
Returns:
True on success, false on failure

bool exists ( Key const &  _key  )  const

Tests whether a key is in the table or not.

Parameters:
_key The key of the node to find.
Returns:
True if the key is in the tree, false if not.

Data find ( Key const &  _key  )  const

Finds a node in the table and returns the data at that node.

Parameters:
_key The key of the item to find.
Returns:
The data at the node. NULL if not found.
Deprecated:
The return value of this function could be unpredictable if the contents of the table was anything but pointers or integers.
See also:
find

bool find ( Key const &  _key,
Data &  _data 
) const

Finds a node in the table and copies the data from that node to a specified location.

Parameters:
_key The key of the node to find.
_data On return, will contain the data at the node. If not found, _data does not change.
Returns:
True on success, false on failure.

bool insert ( Key const &  _key,
Data const &  _data 
)

Inserts data into the table.

Parameters:
_key The key of the data.
_data The data to insert.
Returns:
True on success, false on failure.

size_t mem_usage (  )  const

Returns the overhead caused by the data structure.

Returns:
Memory usage in bytes.

HashTable<Key, Data>& operator= ( const HashTable< Key, Data > &   )  [private]

Private assignment operator.

Not yet written, so declared private for now to prevent an auto-generated one from performing an unexpected operation.

size_t size (  )  const [inline]

Indicates the number of subtrees.

Returns:
Number of subtrees in the table.

size_t used (  )  const [inline]

Indicates the number of items in the table.

Returns:
Number of items in the table.


Generated on Sun Feb 8 11:10:00 2009 for CrissCross by  doxygen 1.5.8