#include <OpenMS/DATASTRUCTURES/HashMap.h>
This class implements a simple hash map using hashing by chaining.
Public Types | |
typedef std::pair< Key, T > | ValueType |
typedef Key | KeyType |
typedef std::pair< Key, T > * | PointerType |
typedef std::reverse_iterator < Iterator > | ReverseIterator |
typedef std::reverse_iterator < ConstIterator > | ConstReverseIterator |
Enums and Constants | |
enum | { INITIAL_CAPACITY = 100, INITIAL_NUMBER_OF_BUCKETS = 50 } |
STL-compliance type definitions | |
typedef ValueType | value_type |
typedef UInt | size_type |
typedef Int | difference_type |
typedef ValueType & | reference |
typedef const ValueType & | const_reference |
typedef ValueType & | pointer |
typedef Iterator | iterator |
typedef ConstIterator | const_iterator |
typedef ReverseIterator | reverse_iterator |
typedef ConstReverseIterator | const_reverse_iterator |
Public Member Functions | |
Iterator | begin () throw () |
Iterator | end () throw () |
ConstIterator | begin () const throw () |
ConstIterator | end () const throw () |
Constructors and Destructors | |
HashMap (UInt initial_capacity=INITIAL_CAPACITY, UInt number_of_buckets=INITIAL_NUMBER_OF_BUCKETS) throw () | |
HashMap (const HashMap &hash_map) throw () | |
virtual | ~HashMap () throw () |
virtual void | clear () throw () |
void | destroy () throw () |
Assignment | |
void | set (const HashMap &hash_map) throw () |
const HashMap & | operator= (const HashMap &hash_map) throw () |
void | get (HashMap &hash_map) const throw () |
void | swap (HashMap &hash_map) throw () |
Accessors | |
UInt | getBucketSize () const throw () |
UInt | getCapacity () const throw () |
UInt | getSize () const throw () |
UInt | size () const throw () |
Iterator | find (const Key &key) throw () |
ConstIterator | find (const Key &key) const throw () |
T & | operator[] (const Key &key) throw () |
const T & | operator[] (const Key &key) const throw (typename HashMap<Key, T>::IllegalKey) |
std::pair< Iterator, bool > | insert (const ValueType &entry) throw () |
Iterator | insert (Iterator pos, const ValueType &entry) throw () |
UInt | erase (const Key &key) throw () |
void | erase (Iterator pos) throw () |
void | erase (Iterator first, Iterator last) throw () |
Predicates | |
bool | has (const Key &key) const throw () |
bool | isEmpty () const throw () |
bool | operator== (const HashMap &hash_map) const throw () |
bool | operator!= (const HashMap &hash_map) const throw () |
Protected Member Functions | |
virtual Node * | newNode_ (const ValueType &value, Node *next) const throw () |
virtual void | deleteNode_ (Node *node) const throw () |
virtual UInt | getHashKey_ (const Key &key) const throw () |
virtual bool | needRehashing_ () const throw () |
virtual void | recalculateCapacity_ () throw () |
PointerType | find_ (const Key &key, UInt &index) throw () |
PointerType | find_ (const Key &key, UInt &index) const throw () |
void | deleteBuckets_ () throw () |
UInt | hash_ (const Key &key) const throw () |
void | rehash_ () throw () |
Protected Attributes | |
Attributes | |
UInt | size_ |
UInt | capacity_ |
std::vector< Node * > | bucket_ |
Classes | |
class | ConstIterator |
HashMap const_iterator class. More... | |
class | IllegalKey |
HashMap illegal key exception. More... | |
class | Iterator |
HashMap iterator class. More... | |
struct | Node |
HashMap node (internal use only). More... |
typedef std::pair<Key, T> ValueType |
typedef Key KeyType |
typedef std::pair<Key, T>* PointerType |
typedef std::reverse_iterator<Iterator> ReverseIterator |
typedef std::reverse_iterator<ConstIterator> ConstReverseIterator |
typedef ValueType value_type |
typedef Int difference_type |
typedef const ValueType& const_reference |
typedef ConstIterator const_iterator |
typedef ReverseIterator reverse_iterator |
anonymous enum |
HashMap | ( | UInt | initial_capacity = INITIAL_CAPACITY , |
|
UInt | number_of_buckets = INITIAL_NUMBER_OF_BUCKETS | |||
) | throw () [inline] |
Default constructor. Create a new and empty hash map.
initial_capacity | the capacity of the hash map | |
number_of_buckets | the number of buckets to create |
virtual ~HashMap | ( | ) | throw () [inline, virtual] |
Destructor.
void clear | ( | ) | throw () [inline, virtual] |
Clear the hash map. Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged.
void destroy | ( | ) | throw () [inline] |
Clear the hash map. Remove all nodes from all buckets. The capacity and the number of buckets remain unchanged. Simply calls clear.
void set | ( | const HashMap< Key, T > & | hash_map | ) | throw () [inline] |
Assignment from another hash map.
hash_map | the hash map to assign from |
Assignment operator. Assign the contents of a hash map to another.
hash_map | the hash map to assign from |
void get | ( | HashMap< Key, T > & | hash_map | ) | const throw () [inline] |
Assign the contents of this hash map to another map.
void swap | ( | HashMap< Key, T > & | hash_map | ) | throw () [inline] |
Swap the contents of two hash maps.
UInt getBucketSize | ( | ) | const throw () [inline] |
Return the number of buckets
UInt getCapacity | ( | ) | const throw () [inline] |
Return the capcacity of the hash map.
UInt getSize | ( | ) | const throw () [inline] |
Return the number of entries in the map.
UInt size | ( | ) | const throw () [inline] |
Return the number of entries in the map.
Iterator find | ( | const Key & | key | ) | throw () [inline] |
Find the element whose key is key
.
ConstIterator find | ( | const Key & | key | ) | const throw () [inline] |
Find the element whose key is key
.
T & operator[] | ( | const Key & | key | ) | throw () [inline] |
Return a mutable reference to the element whose key is key
. If an element with the key key
does not exist, it is inserted.
key | the key |
const T & operator[] | ( | const Key & | key | ) | const throw (typename HashMap<Key, T>::IllegalKey) [inline] |
Return a constant reference to the element whose key is key
.
IllegalKey | if the given key does not exist |
key | the key |
std::pair< typename HashMap< Key, T >::Iterator, bool > insert | ( | const ValueType & | entry | ) | throw () [inline] |
Insert a new entry into the hash map.
Insert a new entry into the hash map. For STL compatibility. The value of pos
is ignored.
UInt erase | ( | const Key & | key | ) | throw () [inline] |
Erase element with key key
.
void erase | ( | Iterator | pos | ) | throw () [inline] |
Erase element at a given position.
pos | an iterator pointing to the element to delete |
Erase a range of elements. Erase all elements in the range first - last
.
bool has | ( | const Key & | key | ) | const throw () [inline] |
Test whether the map contains the given key.
bool isEmpty | ( | ) | const throw () [inline] |
Test whether the map is empty.
bool operator== | ( | const HashMap< Key, T > & | hash_map | ) | const throw () [inline] |
Compare two hash maps.
bool operator!= | ( | const HashMap< Key, T > & | hash_map | ) | const throw () [inline] |
Compare two hash maps.
Iterator begin | ( | ) | throw () [inline] |
Iterator end | ( | ) | throw () [inline] |
ConstIterator begin | ( | ) | const throw () [inline] |
ConstIterator end | ( | ) | const throw () [inline] |
virtual void deleteNode_ | ( | Node * | node | ) | const throw () [protected, virtual] |
UInt getHashKey_ | ( | const Key & | key | ) | const throw () [inline, protected, virtual] |
bool needRehashing_ | ( | ) | const throw () [inline, protected, virtual] |
void recalculateCapacity_ | ( | ) | throw () [inline, protected, virtual] |
PointerType find_ | ( | const Key & | key, | |
UInt & | index | |||
) | throw () [protected] |
PointerType find_ | ( | const Key & | key, | |
UInt & | index | |||
) | const throw () [protected] |
void deleteBuckets_ | ( | ) | throw () [inline, protected] |
UInt hash_ | ( | const Key & | key | ) | const throw () [inline, protected] |
void rehash_ | ( | ) | throw () [inline, protected] |
Generated Tue Apr 1 15:36:43 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |