Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

HashSet< Key > Class Template Reference
[Generic Hash Associative Containers]

Generic Hash Set Class. More...

#include <hashSet.h>

List of all members.

Public Types

typedef Key ValueType
typedef Key KeyType
typedef Key * PointerType
typedef Node * IteratorPosition
Type definitions
typedef ForwardIterator< HashSet<
Key >, ValueType, PointerType,
IteratorTraits > 
Iterator
typedef ConstForwardIterator<
HashSet< Key >, ValueType,
PointerType, IteratorTraits > 
ConstIterator
typedef Iterator iterator
typedef ConstIterator const_iterator
typedef Key value_type
typedef Key key_type
typedef Key * pointer
typedef const Key * const_pointer
typedef Key & reference
typedef const Key & const_reference
typedef Size size_type
typedef Index difference_type
Enums
enum  { INITIAL_CAPACITY = 4, INITIAL_NUMBER_OF_BUCKETS = 3 }

Public Member Functions

Iterator begin () throw ()
Iterator end () throw ()
ConstIterator begin () const throw ()
ConstIterator end () const throw ()
Constructors and Destructors
 HashSet (Size initial_capacity=INITIAL_CAPACITY, Size number_of_buckets=INITIAL_NUMBER_OF_BUCKETS) throw ()
 Default Constructor.
 HashSet (const HashSet &hash_set) throw ()
 Copy Constructor.
virtual ~HashSet () throw ()
 Destructor.
virtual void clear () throw ()
 Clear the hash set.
void destroy () throw ()
 Clear the hash set.
Assignment
void set (const HashSet &hash_set) throw ()
 Assign this HashSet with the contents of another HashSet.
const HashSetoperator= (const HashSet &rhs) throw ()
 Assign this HashSet with the contents of another HashSet.
void get (HashSet &hash_set) const throw ()
 Assign another HashSet with the contents of this HashSet.
void swap (HashSet &hash_set) throw ()
 Swap the contents of two hash sets.
Accessors
Size getBucketSize () const throw ()
 Return the number of buckets.
Size getCapacity () const throw ()
 Return the capcacity of the hash set.
Size getSize () const throw ()
 Return the number of elements in the hash set.
Size size () const throw ()
 Return the number of elements in the hash set.
Iterator find (const Key &key) throw ()
 Find the element whose key is key.
ConstIterator find (const Key &key) const throw ()
 Find the element whose key is key.
std::pair< Iterator, bool > insert (const ValueType &item) throw ()
 Insert a new entry into the hash set.
Iterator insert (Iterator pos, const ValueType &item) throw ()
 Insert a new entry into the hash set.
Size erase (const KeyType &key) throw ()
 Erase element with key key.
void erase (Iterator pos) throw (Exception::IncompatibleIterators, Exception::InvalidIterator)
 Erase element at a given position.
void erase (Iterator f, Iterator l) throw (Exception::IncompatibleIterators)
 Erase a range of elements.
Operators
const HashSetoperator &= (const HashSet &rhs) throw ()
 Intersection operator.
const HashSetoperator|= (const HashSet &rhs) throw ()
 Union operator.
HashSet operator & (const HashSet &rhs) const throw ()
 Intersection operator.
HashSet operator| (const HashSet &rhs) const throw ()
 Union operator.
HashSet operator+ (const HashSet &rhs) const throw ()
 Union operator.
HashSet operator- (const HashSet &rhs) const throw ()
 Difference operator.
const HashSetoperator+= (const HashSet &rhs) throw ()
 Union operator.
const HashSetoperator-= (const HashSet &rhs) throw ()
 Difference operator.
Miscellaneous
virtual void host (Visitor< HashSet< Key > > &visitor) throw ()
 Host a visitor for all set entries.
Predicates
bool has (const Key &key) const throw ()
 Test whether the set contains the key key.
bool isEmpty () const throw ()
 Test whether the set is empty.
bool operator== (const HashSet &hash_set) const throw ()
 Compare two hash sets.
bool operator!= (const HashSet &hash_set) const throw ()
 Compare two hash sets.
Debugging and Diagnostics
bool isValid () const throw ()
 Return true if the hash set is consistent.
virtual void dump (std::ostream &s=std::cout, Size depth=0) const throw ()
 Dump the constent of this instance to an ostream.
Iteration
bool apply (UnaryProcessor< ValueType > &processor) throw ()
 Apply a processor to all keys in this instance.

Protected Member Functions

virtual Node * newNode_ (const ValueType &value, Node *next) const throw ()
virtual void deleteNode_ (Node *node) const throw ()
virtual HashIndex hash (const Key &key) const throw ()
virtual bool needRehashing_ () const throw ()
virtual void rehash () throw ()

Friends

class IteratorTraits


Detailed Description

template<class Key>
class HashSet< Key >

Generic Hash Set Class.


Member Enumeration Documentation

template<class Key>
anonymous enum
 

Enumeration values:
INITIAL_CAPACITY  Initial capacity of the hash set.
INITIAL_NUMBER_OF_BUCKETS  Initial number of buckets.


Constructor & Destructor Documentation

template<class Key>
HashSet< Key >::HashSet Size  initial_capacity = INITIAL_CAPACITY,
Size  number_of_buckets = INITIAL_NUMBER_OF_BUCKETS
throw ()
 

Default Constructor.

template<class Key>
HashSet< Key >::HashSet const HashSet< Key > &  hash_set  )  throw ()
 

Copy Constructor.

template<class Key>
virtual HashSet< Key >::~HashSet  )  throw () [virtual]
 

Destructor.


Member Function Documentation

template<class Key>
bool HashSet< Key >::apply UnaryProcessor< ValueType > &  processor  )  throw ()
 

Apply a processor to all keys in this instance.

Returns:
true if the processor could be applied.

template<class Key>
void HashSet< Key >::clear  )  throw () [virtual]
 

Clear the hash set.

Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged.

template<class Key>
void HashSet< Key >::destroy  )  throw ()
 

Clear the hash set.

Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged. Simply calls clear;

template<class Key>
void HashSet< Key >::dump std::ostream &  s = std::cout,
Size  depth = 0
const throw () [virtual]
 

Dump the constent of this instance to an ostream.

template<class Key>
void HashSet< Key >::erase Iterator  f,
Iterator  l
throw (Exception::IncompatibleIterators)
 

Erase a range of elements.

Erase all elements in the range f - l.

template<class Key>
void HashSet< Key >::erase Iterator  pos  )  throw (Exception::IncompatibleIterators, Exception::InvalidIterator)
 

Erase element at a given position.

Parameters:
pos an iterator pointing to the element to delete

template<class Key>
Size HashSet< Key >::erase const KeyType &  key  )  throw ()
 

Erase element with key key.

Returns:
Size the number of elements erased (0 or 1)

template<class Key>
void HashSet< Key >::get HashSet< Key > &  hash_set  )  const throw ()
 

Assign another HashSet with the contents of this HashSet.

Parameters:
hash_set the HashSet to assign to

template<class Key>
Size HashSet< Key >::getBucketSize  )  const throw ()
 

Return the number of buckets.

template<class Key>
Size HashSet< Key >::getCapacity  )  const throw ()
 

Return the capcacity of the hash set.

template<class Key>
Size HashSet< Key >::getSize  )  const throw ()
 

Return the number of elements in the hash set.

template<class Key>
bool HashSet< Key >::has const Key &  key  )  const throw ()
 

Test whether the set contains the key key.

template<class Key>
void HashSet< Key >::host Visitor< HashSet< Key > > &  visitor  )  throw () [virtual]
 

Host a visitor for all set entries.

template<class Key>
HashSet< Key >::Iterator HashSet< Key >::insert Iterator  pos,
const ValueType &  item
throw ()
 

Insert a new entry into the hash set.

For STL compatibility. The value of pos is ignored.

template<class Key>
std::pair< typename HashSet< Key >::Iterator, bool > HashSet< Key >::insert const ValueType &  item  )  throw ()
 

Insert a new entry into the hash set.

template<class Key>
bool HashSet< Key >::isEmpty  )  const throw ()
 

Test whether the set is empty.

template<class Key>
bool HashSet< Key >::isValid  )  const throw ()
 

Return true if the hash set is consistent.

Condition: the number of entries in all buckets has to be equal the stored number of entries (getSize()).

template<class Key>
HashSet< Key > HashSet< Key >::operator & const HashSet< Key > &  rhs  )  const throw ()
 

Intersection operator.

Compute the intersection of the two hash sets. The left-hand set is not modified.

template<class Key>
const HashSet< Key > & HashSet< Key >::operator &= const HashSet< Key > &  rhs  )  throw ()
 

Intersection operator.

Replace the contents of the current hash set by its intersection with rhs.

template<class Key>
bool HashSet< Key >::operator!= const HashSet< Key > &  hash_set  )  const throw ()
 

Compare two hash sets.

template<class Key>
HashSet< Key > HashSet< Key >::operator+ const HashSet< Key > &  rhs  )  const throw ()
 

Union operator.

See also:
operator|

template<class Key>
const HashSet< Key > & HashSet< Key >::operator+= const HashSet< Key > &  rhs  )  throw ()
 

Union operator.

See also:
operator|=

template<class Key>
HashSet< Key > HashSet< Key >::operator- const HashSet< Key > &  rhs  )  const throw ()
 

Difference operator.

Computes the difference of the two sets, i.e. constructs a set containing the the elements of this set that are not contained in rhs.

template<class Key>
const HashSet< Key > & HashSet< Key >::operator-= const HashSet< Key > &  rhs  )  throw ()
 

Difference operator.

Remove all elements contained in rhs from the set.

template<class Key>
const HashSet< Key > & HashSet< Key >::operator= const HashSet< Key > &  rhs  )  throw ()
 

Assign this HashSet with the contents of another HashSet.

Parameters:
rhs the HashSet to assign from

template<class Key>
bool HashSet< Key >::operator== const HashSet< Key > &  hash_set  )  const throw ()
 

Compare two hash sets.

template<class Key>
HashSet< Key > HashSet< Key >::operator| const HashSet< Key > &  rhs  )  const throw ()
 

Union operator.

Compute the union of the two hash sets. The left-hand set is not modified.

template<class Key>
const HashSet< Key > & HashSet< Key >::operator|= const HashSet< Key > &  rhs  )  throw ()
 

Union operator.

Replace the contents of the current hash set by its union with rhs.

template<class Key>
void HashSet< Key >::set const HashSet< Key > &  hash_set  )  throw ()
 

Assign this HashSet with the contents of another HashSet.

Parameters:
hash_set the HashSet to assign from

template<class Key>
Size HashSet< Key >::size  )  const throw ()
 

Return the number of elements in the hash set.

template<class Key>
void HashSet< Key >::swap HashSet< Key > &  hash_set  )  throw ()
 

Swap the contents of two hash sets.