Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | List of all members
om::util::HashMap< K, V, HashType, SizeType > Class Template Reference

A container class that uses a hash table to map key objects to value objects. More...

#include <omHashMap.h>

Classes

class  BucketIterator
 A class that iterates over hash map elements. More...
 
class  ConstBucketIterator
 A class that iterates over hash map elements but cannot modify the hash map. More...
 
class  ConstIterator
 A class that iterates over hash map elements without the ability to modify them. More...
 
class  Iterator
 A class that iterates over hash map elements. More...
 

Public Member Functions

 HashMap ()
 Create a hash map with the default load factor and number of buckets. More...
 
 HashMap (Float newLoadFactor)
 Create a hash map with the specified load factor and default number of buckets. More...
 
 HashMap (HashType newNumBuckets)
 Create a hash map with the default load factor and specified number of buckets. More...
 
 HashMap (HashType newNumBuckets, Float newLoadFactor)
 Create a hash map with the specified load factor and number of buckets. More...
 
 HashMap (const HashMap &other)
 Create a hash map with the specified load factor and number of buckets. More...
 
HashMapoperator= (const HashMap &other)
 Copy the contents of one hash map into another. More...
 
 ~HashMap ()
 Destroy a hash map and it's contents, deallocating all memory used. More...
 
V * add (HashType keyHash, const K &key, const V &value)
 Add a new mapping to the hash map, associating the given key with the given value. More...
 
Bool set (HashType keyHash, const K &key, const V &value)
 Set the mapping of a key to be the given value, regardless of it's previous state. More...
 
Bool remove (HashType keyHash, const K &key)
 Remove the first mapping of the given key. More...
 
Bool removeAll (HashType keyHash, const K &key)
 Remove the all mappings for the given key. More...
 
Bool remove (HashType keyHash, const K &key, const V &value)
 Remove a specific key-value mapping from the hash map. More...
 
void clear ()
 Clear all mappings from the hash map. More...
 
Bool find (HashType keyHash, const K &key, V *&value)
 Query whether or not the specified key is contained in a hash map. More...
 
Bool find (HashType keyHash, const K &key, const V *&value) const
 Query whether or not the specified key is contained in a hash map. More...
 
Bool contains (HashType keyHash, const K &key) const
 Query whether or not the specified key is contained in a hash map. More...
 
Bool contains (HashType keyHash, const K &key, const V &value) const
 Query whether or not a particular mapping exists in the hash map. More...
 
SizeType getSize () const
 Return the number of mappings in a hash map. More...
 
Bool isEmpty () const
 Return whether or not a hash map is empty. More...
 
V * get (HashType keyHash, const K &key)
 Return a pointer to the value associated with the given key. More...
 
const V * get (HashType keyHash, const K &key) const
 Return a const pointer to the value associated with the given key. More...
 
Iterator getIterator ()
 Return an iterator for the hash map that can modify the hash map. More...
 
ConstIterator getIterator () const
 Return a const-iterator for the hash map. More...
 
BucketIterator getBucketIterator (HashType keyHash)
 Return an iterator for the bucket associated with the specified key hash code. More...
 
ConstBucketIterator getBucketIterator (HashType keyHash) const
 Return an iterator for the bucket associated with the specified key hash code. More...
 
void setLoadFactor (Float newLoadFactor)
 
Float getLoadFactor () const
 

Detailed Description

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
class om::util::HashMap< K, V, HashType, SizeType >

A container class that uses a hash table to map key objects to value objects.

Constructor & Destructor Documentation

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::HashMap ( )
inline

Create a hash map with the default load factor and number of buckets.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::HashMap ( Float  newLoadFactor)
inline

Create a hash map with the specified load factor and default number of buckets.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::HashMap ( HashType  newNumBuckets)
inline

Create a hash map with the default load factor and specified number of buckets.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::HashMap ( HashType  newNumBuckets,
Float  newLoadFactor 
)
inline

Create a hash map with the specified load factor and number of buckets.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::HashMap ( const HashMap< K, V, HashType, SizeType > &  other)
inline

Create a hash map with the specified load factor and number of buckets.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
om::util::HashMap< K, V, HashType, SizeType >::~HashMap ( )
inline

Destroy a hash map and it's contents, deallocating all memory used.

Member Function Documentation

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
HashMap& om::util::HashMap< K, V, HashType, SizeType >::operator= ( const HashMap< K, V, HashType, SizeType > &  other)
inline

Copy the contents of one hash map into another.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
V* om::util::HashMap< K, V, HashType, SizeType >::add ( HashType  keyHash,
const K &  key,
const V &  value 
)
inline

Add a new mapping to the hash map, associating the given key with the given value.

If the add operation was successful, it returns a pointer to the location where the mapping's value is stored. Otherwise, a NULL pointer is returned.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::set ( HashType  keyHash,
const K &  key,
const V &  value 
)
inline

Set the mapping of a key to be the given value, regardless of it's previous state.

The method returns TRUE if the key did not previously exist in the HashMap. Otherwise the method returns FALSE.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::remove ( HashType  keyHash,
const K &  key 
)
inline

Remove the first mapping of the given key.

If the key does not exist in the hash map FALSE is returned, otherwise TRUE is returned.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::removeAll ( HashType  keyHash,
const K &  key 
)
inline

Remove the all mappings for the given key.

The method returns whether or not any mappings were removed from the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::remove ( HashType  keyHash,
const K &  key,
const V &  value 
)
inline

Remove a specific key-value mapping from the hash map.

The method returns whether or not the key-value pair was successfully found and removed from the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
void om::util::HashMap< K, V, HashType, SizeType >::clear ( )
inline

Clear all mappings from the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::find ( HashType  keyHash,
const K &  key,
V *&  value 
)
inline

Query whether or not the specified key is contained in a hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::find ( HashType  keyHash,
const K &  key,
const V *&  value 
) const
inline

Query whether or not the specified key is contained in a hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::contains ( HashType  keyHash,
const K &  key 
) const
inline

Query whether or not the specified key is contained in a hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::contains ( HashType  keyHash,
const K &  key,
const V &  value 
) const
inline

Query whether or not a particular mapping exists in the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
SizeType om::util::HashMap< K, V, HashType, SizeType >::getSize ( ) const
inline

Return the number of mappings in a hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Bool om::util::HashMap< K, V, HashType, SizeType >::isEmpty ( ) const
inline

Return whether or not a hash map is empty.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
V* om::util::HashMap< K, V, HashType, SizeType >::get ( HashType  keyHash,
const K &  key 
)
inline

Return a pointer to the value associated with the given key.

If the key does not exist in the hash map, a NULL pointer is returned.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
const V* om::util::HashMap< K, V, HashType, SizeType >::get ( HashType  keyHash,
const K &  key 
) const
inline

Return a const pointer to the value associated with the given key.

If the key does not exist in the hash map, a NULL pointer is returned.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Iterator om::util::HashMap< K, V, HashType, SizeType >::getIterator ( )
inline

Return an iterator for the hash map that can modify the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
ConstIterator om::util::HashMap< K, V, HashType, SizeType >::getIterator ( ) const
inline

Return a const-iterator for the hash map.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
BucketIterator om::util::HashMap< K, V, HashType, SizeType >::getBucketIterator ( HashType  keyHash)
inline

Return an iterator for the bucket associated with the specified key hash code.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
ConstBucketIterator om::util::HashMap< K, V, HashType, SizeType >::getBucketIterator ( HashType  keyHash) const
inline

Return an iterator for the bucket associated with the specified key hash code.

template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
void om::util::HashMap< K, V, HashType, SizeType >::setLoadFactor ( Float  newLoadFactor)
inline
template<typename K, typename V, typename HashType = Hash, typename SizeType = Size>
Float om::util::HashMap< K, V, HashType, SizeType >::getLoadFactor ( ) const
inline

The documentation for this class was generated from the following file: