ScummVM API documentation
Hash table (HashMap)

Description

API for operations on a hash table.

Modules

 Hash table pointer
 Template for a HashMap pointer.
 

Classes

class  Common::HashMap< Key, Val, HashFunc, EqualFunc >
 

Functions

template<class Key >
void NORETURN_PRE Common::unknownKeyError (Key k) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (::Common::String key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (signed char key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (unsigned char key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (short signed key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (short unsigned key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (long signed key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (long unsigned key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (signed int key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (unsigned int key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (long long signed key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (long long unsigned key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (void *key) NORETURN_POST
 
template<>
void NORETURN_PRE Common::unknownKeyError (const char *key) NORETURN_POST
 
 Common::HashMap< Key, Val, HashFunc, EqualFunc >::HashMap ()
 
 Common::HashMap< Key, Val, HashFunc, EqualFunc >::HashMap (const HM_t &map)
 
 Common::HashMap< Key, Val, HashFunc, EqualFunc >::~HashMap ()
 
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::clear (bool shrinkArray=0)
 
bool Common::HashMap< Key, Val, HashFunc, EqualFunc >::contains (const Key &key) const
 
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::operator[] (const Key &key)
 
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::operator[] (const Key &key) const
 
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getOrCreateVal (const Key &key)
 
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getVal (const Key &key)
 
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getVal (const Key &key) const
 
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getValOrDefault (const Key &key) const
 
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getValOrDefault (const Key &key, const Val &defaultVal) const
 
bool Common::HashMap< Key, Val, HashFunc, EqualFunc >::tryGetVal (const Key &key, Val &out) const
 
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::setVal (const Key &key, const Val &val)
 
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::erase (iterator entry)
 
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::erase (const Key &key)
 

Function Documentation

◆ HashMap() [1/2]

template<class Key , class Val , class HashFunc , class EqualFunc >
Common::HashMap< Key, Val, HashFunc, EqualFunc >::HashMap ( )

Base constructor, creates an empty hashmap.

◆ HashMap() [2/2]

template<class Key , class Val , class HashFunc , class EqualFunc >
Common::HashMap< Key, Val, HashFunc, EqualFunc >::HashMap ( const HM_t map)

Copy constructor, creates a full copy of the given hashmap. A custom copy constructor must be provided as pointers to heap buffers are used for the internal storage.

◆ ~HashMap()

template<class Key , class Val , class HashFunc , class EqualFunc >
Common::HashMap< Key, Val, HashFunc, EqualFunc >::~HashMap ( )

Destructor, frees all used memory.

◆ clear()

template<class Key , class Val , class HashFunc , class EqualFunc >
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::clear ( bool  shrinkArray = 0)

Clear all values in the hashmap.

◆ contains()

template<class Key, class Val , class HashFunc , class EqualFunc >
bool Common::HashMap< Key, Val, HashFunc, EqualFunc >::contains ( const Key &  key) const

Check whether the hashmap contains the given key.

◆ operator[]() [1/2]

template<class Key, class Val , class HashFunc , class EqualFunc >
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::operator[] ( const Key &  key)

Get a value from the hashmap.

◆ operator[]() [2/2]

template<class Key, class Val , class HashFunc , class EqualFunc >
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::operator[] ( const Key &  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getOrCreateVal()

template<class Key, class Val , class HashFunc , class EqualFunc >
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getOrCreateVal ( const Key &  key)

Get a value from the hashmap.

◆ getVal()

template<class Key, class Val , class HashFunc , class EqualFunc >
Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getVal ( const Key &  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getValOrDefault()

template<class Key, class Val, class HashFunc , class EqualFunc >
const Val & Common::HashMap< Key, Val, HashFunc, EqualFunc >::getValOrDefault ( const Key &  key,
const Val &  defaultVal 
) const

Get a value from the hashmap. If the key is not present, then return defaultVal.

◆ tryGetVal()

template<class Key, class Val, class HashFunc , class EqualFunc >
bool Common::HashMap< Key, Val, HashFunc, EqualFunc >::tryGetVal ( const Key &  key,
Val &  out 
) const

Assign an element specified by key to a value val.

◆ erase() [1/2]

template<class Key , class Val , class HashFunc , class EqualFunc >
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::erase ( iterator  entry)

Erase an element referred to by an iterator.

◆ erase() [2/2]

template<class Key, class Val , class HashFunc , class EqualFunc >
void Common::HashMap< Key, Val, HashFunc, EqualFunc >::erase ( const Key &  key)

Erase an element specified by a key.