Hash map template class. More...

#include <HashMap.h>

Inheritance diagram for Urho3D::HashMap< T, U >:
[legend]
Collaboration diagram for Urho3D::HashMap< T, U >:
[legend]

Classes

struct  ConstIterator
 Hash map node const iterator. More...
 
struct  Iterator
 Hash map node iterator. More...
 
class  KeyValue
 Hash map key-value pair with const key. More...
 
struct  Node
 Hash map node. More...
 

Public Types

typedef T KeyType
 
typedef U ValueType
 

Public Member Functions

 HashMap ()
 Construct empty.
 
 HashMap (const HashMap< T, U > &map)
 Construct from another hash map.
 
 ~HashMap ()
 Destruct.
 
HashMapoperator= (const HashMap< T, U > &rhs)
 Assign a hash map.
 
HashMapoperator+= (const Pair< T, U > &rhs)
 Add-assign a pair.
 
HashMapoperator+= (const HashMap< T, U > &rhs)
 Add-assign a hash map.
 
bool operator== (const HashMap< T, U > &rhs) const
 Test for equality with another hash map.
 
bool operator!= (const HashMap< T, U > &rhs) const
 Test for inequality with another hash map.
 
U & operator[] (const T &key)
 Index the map. Create a new pair if key not found.
 
U * operator[] (const T &key) const
 Index the map. Return null if key is not found, does not create a new pair.
 
Iterator Insert (const Pair< T, U > &pair)
 Insert a pair. Return an iterator to it.
 
void Insert (const HashMap< T, U > &map)
 Insert a map.
 
Iterator Insert (const ConstIterator &it)
 Insert a pair by iterator. Return iterator to the value.
 
void Insert (const ConstIterator &start, const ConstIterator &end)
 Insert a range by iterators.
 
bool Erase (const T &key)
 Erase a pair by key. Return true if was found.
 
Iterator Erase (const Iterator &it)
 Erase a pair by iterator. Return iterator to the next pair.
 
void Clear ()
 Clear the map.
 
void Sort ()
 Sort pairs. After sorting the map can be iterated in order until new elements are inserted.
 
bool Rehash (unsigned numBuckets)
 Rehash to a specific bucket count, which must be a power of two. Return true if successful.
 
Iterator Find (const T &key)
 Return iterator to the pair with key, or end iterator if not found.
 
ConstIterator Find (const T &key) const
 Return const iterator to the pair with key, or end iterator if not found.
 
bool Contains (const T &key) const
 Return whether contains a pair with key.
 
Vector< T > Keys () const
 Return all the keys.
 
Vector< U > Values () const
 Return all the values.
 
Iterator Begin ()
 Return iterator to the beginning.
 
ConstIterator Begin () const
 Return iterator to the beginning.
 
Iterator End ()
 Return iterator to the end.
 
ConstIterator End () const
 Return iterator to the end.
 
const T & Front () const
 Return first key.
 
const T & Back () const
 Return last key.
 
- Public Member Functions inherited from Urho3D::HashBase
 HashBase ()
 Construct.
 
void Swap (HashBase &rhs)
 Swap with another hash set or map.
 
unsigned Size () const
 Return number of elements.
 
unsigned NumBuckets () const
 Return number of buckets.
 
bool Empty () const
 Return whether has no elements.
 

Private Member Functions

NodeHead () const
 Return the head node.
 
NodeTail () const
 Return the tail node.
 
NodeFindNode (const T &key, unsigned hashKey) const
 Find a node from the buckets. Do not call if the buckets have not been allocated.
 
NodeFindNode (const T &key, unsigned hashKey, Node *&previous) const
 Find a node and the previous node from the buckets. Do not call if the buckets have not been allocated.
 
NodeInsertNode (const T &key, const U &value, bool findExisting=true)
 Insert a key and value and return either the new or existing node.
 
NodeInsertNode (Node *dest, const T &key, const U &value)
 Insert a node into the list. Return the new node.
 
NodeEraseNode (Node *node)
 Erase a node from the list. Return pointer to the next element, or to the end if could not erase.
 
NodeReserveNode ()
 Reserve a node.
 
NodeReserveNode (const T &key, const U &value)
 Reserve a node with specified key and value.
 
void FreeNode (Node *node)
 Free a node.
 
void Rehash ()
 Rehash the buckets.
 
unsigned Hash (const T &key) const
 Compute a hash based on the key and the bucket size.
 

Static Private Member Functions

static bool CompareNodes (Node *&lhs, Node *&rhs)
 Compare two nodes.
 

Additional Inherited Members

- Static Public Attributes inherited from Urho3D::HashBase
static const unsigned MIN_BUCKETS = 8
 Initial amount of buckets.
 
static const unsigned MAX_LOAD_FACTOR = 4
 Maximum load factor.
 
- Protected Member Functions inherited from Urho3D::HashBase
void AllocateBuckets (unsigned size, unsigned numBuckets)
 Allocate bucket head pointers + room for size and bucket count variables.
 
void ResetPtrs ()
 Reset bucket head pointers.
 
void SetSize (unsigned size)
 Set new size.
 
HashNodeBase ** Ptrs () const
 Return bucket head pointers.
 
- Protected Attributes inherited from Urho3D::HashBase
HashNodeBasehead_
 List head node pointer.
 
HashNodeBasetail_
 List tail node pointer.
 
HashNodeBase ** ptrs_
 Bucket head pointers.
 
AllocatorBlockallocator_
 Node allocator.
 

Detailed Description

template<class T, class U>
class Urho3D::HashMap< T, U >

Hash map template class.


The documentation for this class was generated from the following file:
  • /home/travis/build/urho3d/Urho3D/Source/Urho3D/Container/HashMap.h