DSC Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
DSC::HashMap< K, V, H, S > Class Template Reference

Generic hash map. More...

#include <hash_map.hpp>

Classes

struct  Entry
 
class  iterator
 
struct  MapEntry
 

Public Member Functions

bool contains_key (const K &key) const
 checks if a key exists in the hash map More...
 
V & operator[] (const K &key)
 get left-value reference to the value held by a key More...
 
const V & operator[] (const K &key) const
 get right-value reference to the value held by a key More...
 
void remove_key (const K &key)
 removes key from the hash map More...
 
int size () const
 
void clear ()
 
 HashMap (const HashMap< K, V, H, S > &other)
 
 HashMap (HashMap< K, V, H, S > &&other)
 
HashMap< K, V, H, S > & operator= (const HashMap< K, V, H, S > &other)
 
HashMap< K, V, H, S > & operator= (HashMap< K, V, H, S > &&other)
 
iterator begin ()
 
iterator end ()
 

Detailed Description

template<typename K, typename V, int(*)(const K &) H = default_hash<K, 128>, int S = 128>
class DSC::HashMap< K, V, H, S >

Generic hash map.

Template Parameters
Ktype of keys
Vtype of values
Hhash function for keys
Shash container size (H(k) maps k to 0..S-1)

Member Function Documentation

◆ contains_key()

template<typename K , typename V , int(*)(const K &) H, int S>
bool DSC::HashMap< K, V, H, S >::contains_key ( const K &  key) const

checks if a key exists in the hash map

Parameters
keykey to check
Returns
true if key exists, false otherwise

◆ operator[]() [1/2]

template<typename K , typename V , int(*)(const K &) H, int S>
V & DSC::HashMap< K, V, H, S >::operator[] ( const K &  key)

get left-value reference to the value held by a key

Parameters
keykey to access
Returns
value of the key

if the key does not exist, it is created automatically

◆ operator[]() [2/2]

template<typename K , typename V , int(*)(const K &) H, int S>
const V & DSC::HashMap< K, V, H, S >::operator[] ( const K &  key) const

get right-value reference to the value held by a key

Parameters
keykey to access
Returns
value of the key

raises fatal error if key does not exist in the hash map

◆ remove_key()

template<typename K , typename V , int(*)(const K &) H, int S>
void DSC::HashMap< K, V, H, S >::remove_key ( const K &  key)

removes key from the hash map

Parameters
keykey to remove

if key doesn't exist, it is simply ignored


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