#include <hashSet.h>
Classes |
|
class | IllegalKey |
Illegal key exception. More... |
|
Public Types |
|
typedef Key | ValueType |
typedef Key | KeyType |
typedef Key * | PointerType |
typedef Node * | IteratorPosition |
Enums
|
|
enum | { INITIAL_CAPACITY = 4, INITIAL_NUMBER_OF_BUCKETS = 3 } |
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 |
Public Member Functions |
|
Iterator | begin () |
Iterator | end () |
ConstIterator | begin () const |
ConstIterator | end () const |
Constructors and Destructors
|
|
HashSet (Size initial_capacity=INITIAL_CAPACITY, Size number_of_buckets=INITIAL_NUMBER_OF_BUCKETS) | |
Default Constructor. |
|
HashSet (const HashSet &hash_set) | |
Copy Constructor. |
|
virtual | ~HashSet () |
Destructor. |
|
virtual void | clear () |
Clear the hash set. |
|
void | destroy () |
Clear the hash set. |
|
Assignment
|
|
void | set (const HashSet &hash_set) |
Assign this HashSet with the contents of
another HashSet. |
|
const HashSet & | operator= (const HashSet &rhs) |
Assign this HashSet with the contents of
another HashSet. |
|
void | get (HashSet &hash_set) const |
Assign another HashSet with the contents of
this HashSet. |
|
void | swap (HashSet &hash_set) |
Swap the contents of two hash
sets. |
|
Accessors
|
|
Size | getBucketSize () const |
Return the number of
buckets. |
|
Size | getCapacity () const |
Return the capcacity of the hash
set. |
|
Size | getSize () const |
Return the number of elements in the
hash set. |
|
Size | size () const |
Return the number of elements in the
hash set. |
|
Iterator | find (const Key &key) |
Find the element whose key is
key . |
|
ConstIterator | find (const Key &key) const |
Find the element whose key is
key . |
|
std::pair< Iterator, bool > | insert (const ValueType &item) |
Insert a new entry into the hash
set. |
|
Iterator | insert (Iterator pos, const ValueType &item) |
Insert a new entry into the hash
set. |
|
Size | erase (const KeyType &key) |
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 HashSet & | operator&= (const HashSet &rhs) |
Intersection operator. |
|
const HashSet & | operator|= (const HashSet &rhs) |
Union operator. |
|
HashSet | operator& (const HashSet &rhs) const |
Intersection operator. |
|
HashSet | operator| (const HashSet &rhs) const |
Union operator. |
|
HashSet | operator+ (const HashSet &rhs) const |
Union operator. |
|
HashSet | operator- (const HashSet &rhs) const |
Difference operator. |
|
const HashSet & | operator+= (const HashSet &rhs) |
Union operator. |
|
const HashSet & | operator-= (const HashSet &rhs) |
Difference operator. |
|
Miscellaneous
|
|
virtual void | host (Visitor< HashSet< Key > > &visitor) |
Host a visitor for all set
entries. |
|
Predicates
|
|
bool | has (const Key &key) const |
Test whether the set contains the
key key . |
|
bool | isEmpty () const |
Test whether the set is
empty. |
|
bool | operator== (const HashSet &hash_set) const |
Compare two hash sets. |
|
bool | operator!= (const HashSet &hash_set) const |
Compare two hash sets. |
|
Debugging and Diagnostics
|
|
bool | isValid () const |
Return true if the hash set is
consistent. |
|
virtual void | dump (std::ostream &s=std::cout, Size depth=0) const |
Dump the constent of this instance
to an ostream. |
|
Iteration
|
|
bool | apply (UnaryProcessor< ValueType > &processor) |
Apply a processor to all keys in
this instance. |
|
Protected Member Functions |
|
virtual Node * | newNode_ (const ValueType &value, Node *next) const |
virtual void | deleteNode_ (Node *node) const |
virtual HashIndex | hash (const Key &key) const |
virtual bool | needRehashing_ () const |
virtual void | rehash () |
Friends |
|
class | IteratorTraits |
anonymous enum |
bool BALL::HashSet< Key >::apply | ( | UnaryProcessor< ValueType > & | processor | ) |
Apply a processor to all keys in this instance.
References BALL::Processor::BREAK, BALL::UnaryProcessor< T >::finish(), and BALL::UnaryProcessor< T >::start().
void BALL::HashSet< Key >::clear | ( | ) | [virtual] |
Clear the hash set.
Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged.
Referenced by BALL::HashSet< Key >::destroy(), and BALL::HashSet< Key >::operator-=().
void BALL::HashSet< Key >::destroy | ( | ) |
Clear the hash set.
Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged. Simply calls clear;
References BALL::HashSet< Key >::clear().
Referenced by BALL::HashSet< Key >::set().
void BALL::HashSet< Key >::erase | ( | Iterator | f, | |
Iterator | l | |||
) | throw (Exception::IncompatibleIterators) |
Erase a range of elements.
Erase all elements in the range f - l
.
void BALL::HashSet< Key >::erase | ( | Iterator | pos | ) | throw (Exception::IncompatibleIterators, Exception::InvalidIterator) |
Erase element at a given position.
pos | an iterator pointing to the element to delete |
Size BALL::HashSet< Key >::erase | ( | const KeyType & | key | ) |
Erase element with key key
.
Referenced by BALL::HashSet< Key >::operator&=(), BALL::HashSet< Key >::operator-=(), and BALL::GraphVertex< Vertex, Edge, Face >::remove().
void BALL::HashSet< Key >::get | ( | HashSet< Key > & | hash_set | ) | const |
Assign another HashSet with the contents of this HashSet.
hash_set | the HashSet to assign to |
References BALL::HashSet< Key >::set().
Iterator BALL::HashSet< Key >::insert | ( | Iterator | pos, | |
const ValueType & | item | |||
) |
Insert a new entry into the hash set.
For STL compatibility. The value of pos
is
ignored.
bool BALL::HashSet< Key >::isValid | ( | ) | const |
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()).
References BALL::HashSet< Key >::size().
HashSet< Key > BALL::HashSet< Key >::operator& | ( | const HashSet< Key > & | rhs | ) | const |
Intersection operator.
Compute the intersection of the two hash sets. The left-hand set is not modified.
References BALL::HashSet< Key >::has(), and BALL::HashSet< Key >::insert().
const HashSet< Key > & BALL::HashSet< Key >::operator&= | ( | const HashSet< Key > & | rhs | ) |
Intersection operator.
Replace the contents of the current hash set by its
intersection with rhs
.
References BALL::HashSet< Key >::begin(), BALL::HashSet< Key >::erase(), and BALL::HashSet< Key >::has().
HashSet< Key > BALL::HashSet< Key >::operator+ | ( | const HashSet< Key > & | rhs | ) | const |
const HashSet< Key > & BALL::HashSet< Key >::operator+= | ( | const HashSet< Key > & | rhs | ) |
HashSet< Key > BALL::HashSet< Key >::operator- | ( | const HashSet< Key > & | rhs | ) | const |
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
.
References BALL::HashSet< Key >::has(), and BALL::HashSet< Key >::insert().
const HashSet< Key > & BALL::HashSet< Key >::operator-= | ( | const HashSet< Key > & | rhs | ) |
Difference operator.
Remove all elements contained in rhs
from
the set.
References BALL::HashSet< Key >::begin(), BALL::HashSet< Key >::clear(), BALL::HashSet< Key >::end(), BALL::HashSet< Key >::erase(), and BALL::HashSet< Key >::has().
const HashSet< Key > & BALL::HashSet< Key >::operator= | ( | const HashSet< Key > & | rhs | ) |
HashSet< Key > BALL::HashSet< Key >::operator| | ( | const HashSet< Key > & | rhs | ) | const |
Union operator.
Compute the union of the two hash sets. The left-hand set is not modified.
Referenced by BALL::HashSet< Key >::operator+().
const HashSet< Key > & BALL::HashSet< Key >::operator|= | ( | const HashSet< Key > & | rhs | ) |
Union operator.
Replace the contents of the current hash set by its
union with rhs
.
References BALL::HashSet< Key >::begin(), BALL::HashSet< Key >::end(), and BALL::HashSet< Key >::insert().
Referenced by BALL::HashSet< Key >::operator+=().
void BALL::HashSet< Key >::set | ( | const HashSet< Key > & | hash_set | ) |
Assign this HashSet with the contents of another HashSet.
hash_set | the HashSet to assign from |
References BALL::HashSet< Key >::bucket_, BALL::HashSet< Key >::capacity_, BALL::HashSet< Key >::destroy(), and BALL::HashSet< Key >::size_.
Referenced by BALL::HashSet< Key >::get().