Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide


Module:  Essential Tools Module   Group:  RWCollectable


Local Index



#include <rw/hashtab.h>
RWHashTable h ;


This class is a simple hash table for objects inheriting from RWCollectable. It uses chaining (as implemented by class RWSlistCollectables) to resolve hash collisions. Duplicate objects are allowed. An object stored by RWHashTable must inherit from the abstract base class RWCollectable, with suitable definition for virtual functions hash() and isEqual() (see class RWCollectable).

To find an object that matches a key, the key's virtual function hash() is first called to determine in which bucket the object occurs. The bucket is then searched linearly by calling the virtual function isEqual() for each candidate, with the key as the argument. The first object to return TRUE is the returned object.

The initial number of buckets in the table is set by the constructor. There is a default value. If the number of items in the collection greatly exceeds the number of buckets then efficiency will sag because each bucket must be searched linearly. The number of buckets can be changed by calling member function resize(). This will require that all objects be rehashed.

The iterator for this class is RWHashTableIterator.




Program output:

Public Constructors

RWHashTable(size_t N = RWCollection::DEFAULT_CAPACITY);
RWHashTable(const RWHashTable& t);

Public Operators

operator=(const RWHashTable& t);
operator==(const RWHashTable& t) const;
operator<=(const RWHashTable& t) const;
operator!=(const RWHashTable&) const;

Member Functions

virtual void
apply(RWapplyCollectable ap, void*);
virtual RWspace
binaryStoreSize() const;
virtual void
virtual void
virtual int
compareTo(const RWCollectable*) const;
virtual RWBoolean
contains(const RWCollectable*) const;
virtual size_t
entries() const;
virtual RWCollectable*
find(const RWCollectable*) const;
virtual unsigned
hash() const;
virtual RWCollectable*
insert(RWCollectable* a);
virtual RWClassID
isA() const;
virtual RWBoolean
isEmpty() const;
virtual RWBoolean
isEqual(const RWCollectable*) const;
virtual RWCollectable*
newSpecies() const;
virtual size_t
occurrencesOf(const RWCollectable*) const;
virtual RWCollectable*
remove(const RWCollectable*);
virtual void
removeAndDestroy(const RWCollectable*); 
virtual void
resize(size_t n = 0);
virtual void
virtual void
virtual void
saveGuts(RWvostream&) const;
virtual void
saveGuts(RWFile&) const;

Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.