Map< Key, Value, Sequence > Class Template Reference

#include <tDictionary.h>

Inheritance diagram for Map< Key, Value, Sequence >:

Inheritance graph
[legend]
List of all members.

Detailed Description


template<typename Key, typename Value, class Sequence = HashTable<Key,Value>> class Map< Key, Value, Sequence >

A Map template class.

The map class maps between a key and an associated value. Keys are unique. The hash table class is used as the default implementation so the the key must be hashable, see util/hash.h for details.


Public Types

typedef Parent::Pair Pair
typedef Pair ValueType
typedef PairReference
typedef const PairConstReference
typedef Parent::Iterator Iterator
typedef Parent::ConstIterator ConstIterator
typedef S32 DifferenceType
typedef U32 SizeType

Public Member Functions

 Map ()
 ~Map ()
 Map (const Map &p)
U32 size () const
 Return the number of elements.
void clear ()
 Empty the Map.
bool isEmpty () const
 Returns true if the map is empty.
Iterator insert (const Key &key, const Value &)
 Insert the key value pair but don't allow duplicates.
void erase (Iterator)
 Erase the given entry.
void erase (const Key &key)
 Erase the key from the map.
Iterator find (const Key &)
 Find entry for the given key.
ConstIterator find (const Key &) const
 Find entry for the given key.
bool contains (const Key &a)
Iterator begin ()
 Iterator to first element.
ConstIterator begin () const
 Iterator to first element.
Iterator end ()
 IIterator to last element + 1.
ConstIterator end () const
 Iterator to last element + 1.
Value & operator[] (const Key &)
 Index using the given key. If the key is not currently in the map it is added.

Private Types

typedef HashTable< Key, Value > Parent

Private Attributes

Sequence mMap


Member Typedef Documentation

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef HashTable<Key,Value> Map< Key, Value, Sequence >::Parent [private]

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef Parent::Pair Map< Key, Value, Sequence >::Pair

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef Pair Map< Key, Value, Sequence >::ValueType

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef Pair& Map< Key, Value, Sequence >::Reference

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef const Pair& Map< Key, Value, Sequence >::ConstReference

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef Parent::Iterator Map< Key, Value, Sequence >::Iterator

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef Parent::ConstIterator Map< Key, Value, Sequence >::ConstIterator

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef S32 Map< Key, Value, Sequence >::DifferenceType

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
typedef U32 Map< Key, Value, Sequence >::SizeType


Constructor & Destructor Documentation

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
Map< Key, Value, Sequence >::Map (  )  [inline]

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
Map< Key, Value, Sequence >::~Map (  )  [inline]

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::Map ( const Map< Key, Value, Sequence > &  p  ) 


Member Function Documentation

template<typename Key, typename Value, class Sequence>
U32 Map< Key, Value, Sequence >::size (  )  const [inline]

Return the number of elements.

template<typename Key, typename Value, class Sequence>
void Map< Key, Value, Sequence >::clear (  )  [inline]

Empty the Map.

template<typename Key, typename Value, class Sequence>
bool Map< Key, Value, Sequence >::isEmpty (  )  const [inline]

Returns true if the map is empty.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::Iterator Map< Key, Value, Sequence >::insert ( const Key &  key,
const Value &  x 
)

Insert the key value pair but don't allow duplicates.

The map class does not allow duplicates keys. If the key already exists in the map the function will fail and return end().

template<typename Key, typename Value, class Sequence>
void Map< Key, Value, Sequence >::erase ( Iterator   ) 

Erase the given entry.

template<typename Key, typename Value, class Sequence>
void Map< Key, Value, Sequence >::erase ( const Key &  key  ) 

Erase the key from the map.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::Iterator Map< Key, Value, Sequence >::find ( const Key &   ) 

Find entry for the given key.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::ConstIterator Map< Key, Value, Sequence >::find ( const Key &   )  const

Find entry for the given key.

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
bool Map< Key, Value, Sequence >::contains ( const Key &  a  )  [inline]

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::Iterator Map< Key, Value, Sequence >::begin (  )  [inline]

Iterator to first element.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::ConstIterator Map< Key, Value, Sequence >::begin (  )  const [inline]

Iterator to first element.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::Iterator Map< Key, Value, Sequence >::end (  )  [inline]

IIterator to last element + 1.

template<typename Key, typename Value, class Sequence>
Map< Key, Value, Sequence >::ConstIterator Map< Key, Value, Sequence >::end (  )  const [inline]

Iterator to last element + 1.

template<typename Key, typename Value, class Sequence>
Value & Map< Key, Value, Sequence >::operator[] ( const Key &   )  [inline]

Index using the given key. If the key is not currently in the map it is added.


Member Data Documentation

template<typename Key, typename Value, class Sequence = HashTable<Key,Value>>
Sequence Map< Key, Value, Sequence >::mMap [private]