Class hierarchy Compound list Compound Members
Hashtable Class Reference
A hashtable is a set of unique elements. More...
Inherits Container.
List of all members.
Public Members
- Hashtable (const unsigned flags=0)
- Default Constructor: Construct an empty hash table.
- Hashtable (const Hashtable&)
- Copy Constructor: Construct a copy of a hash table.
- Hashtable (const Container&)
- Construct a hashtable from any container.
- Hashtable (const Enumeration&)
- Construct a hashtable from an enumeration.
- Hashtable (const Vector&)
- Contruct a hashtable from from a vector.
- ~Hashtable ()
- Destructor.
- Hashtable& operator= (const Hashtable&)
- Assignment: Copy a hash table.
- virtual int load (const Vector& v)
- Load this hashtable with the elements from a vector.
- virtual int put (const Data item, const int index=-1)
- Add a data item to this hashtable.
- int load (const Enumeration& e)
- Load this hashtable from an enumeration.
- virtual int load (Enumeration&, int temp=0)
- Load this hashtable with a non-const enumeration and optionally discard source if temp is non-zero.
- virtual Data get (const Data item) const
- Retrieve a data item from this hashtable.
- virtual Data get (const int index) const
- Retrieve an item by index.
- virtual Data pop ()
- Pop: Get and remove an item.
- virtual DS_BOOL remove (const Data item)
- Remove an item.
- virtual void remove (const int index)
- Remove an item by index.
- virtual DS_BOOL contains (const Data item) const
- Returns non-zero if the item is in this hashtable.
- virtual int size () const
- Number of elements in this hashtable.
- virtual void clear ()
- Remove all elements from this hashtable.
- virtual Enumeration elements () const
- Return an enumeration of all elements in this hashtable.
Detailed Description
A hashtable is a set of unique elements.
Each element is identified by its hash value (see Containable)
Note: In non-destructive hashtables, elements must not be deleted
before they are removed from the table.
All methods that accept "Data" ( except put() ) do not require
the actual item (this would be rediculous) but a containable
that has the same hash value as the required item.
Member Function Documentation
Hashtable::Hashtable(const unsigned flags=0)
Default Constructor: Construct an empty hash table.
Hashtable::Hashtable(const Hashtable&)
Copy Constructor: Construct a copy of a hash table.
Hashtable::Hashtable(const Container&)
Construct a hashtable from any container.
Note that only the first of any duplicate entries (according to
Containable::equals()) will be added from the container.
Hashtable::Hashtable(const Enumeration&)
Construct a hashtable from an enumeration.
Hashtable::Hashtable(const Vector&)
Contruct a hashtable from from a vector.
Hashtable::~Hashtable()
Hashtable& Hashtable::operator=(const Hashtable&)
Assignment: Copy a hash table.
virtual int Hashtable::load(const Vector& v) [virtual]
Load this hashtable with the elements from a vector.
virtual int Hashtable::put(const Data item, const int index=-1) [virtual]
Add a data item to this hashtable.
When index == -1 (the default),
if an item with the same key exists, it is replaced (and deleted if
this hashtable isDestuctive()) and zero is returned;
otherwise, (new key) the item is added to the hashtable and 1 is returned.
When index >= 0 and index < size(), after the item at that index is removed (and
deleted if this container isDestructive()), the item is added as above. Note
that this may cause another item to be removed from the table (if one with the
same key exists). Returns -1 if two items are removed, otherwise 0 (no change
in table size).
If index < -1 or index > size(), IndexOutOfBounds is thrown.
int Hashtable::load(const Enumeration& e)
Load this hashtable from an enumeration.
Reimplemented from Container.
virtual int Hashtable::load(Enumeration&, int temp=0) [virtual]
Load this hashtable with a non-const enumeration and optionally discard source if temp is non-zero.
Invaildates e if temp.
Reimplemented from Container.
virtual Data Hashtable::get(const Data item) const [virtual]
Retrieve a data item from this hashtable.
If an item is found in this hashtable with the same key
(as determined by Containable::equals()==), it is returned;
otherwise, (not found) NULL is returned.
Reimplemented from Container.
virtual Data Hashtable::get(const int index) const [virtual]
Retrieve an item by index.
Reimplemented from Container.
virtual Data Hashtable::pop() [virtual]
Pop: Get and remove an item.
Reimplemented from Container.
virtual DS_BOOL Hashtable::remove(const Data item) [virtual]
Remove an item.
item must conform to Container::get() rules.
If the data item exists in this hashtable, it is removed and
non-zero is returned; otherwise, (not found) zero is returned.
Reimplemented from Container.
virtual void Hashtable::remove(const int index) [virtual]
Remove an item by index.
Reimplemented from Container.
virtual DS_BOOL Hashtable::contains(const Data item) const [virtual]
Returns non-zero if the item is in this hashtable.
Reimplemented from Container.
virtual int Hashtable::size() const [virtual]
Number of elements in this hashtable.
Reimplemented from Container.
virtual void Hashtable::clear() [virtual]
Remove all elements from this hashtable.
Reimplemented from Container.
virtual Enumeration Hashtable::elements() const [virtual]
Return an enumeration of all elements in this hashtable.
This is a copy (snapshot) of the elements, so this hashtable can
be modified while iterating through the enumeration.
Reimplemented from Container.
The documentation for this class was generated from the following file: