Implementation of simple mapping class. More...
#include <smallmap_type.hpp>
Public Types | |
typedef ::SmallPair< T, U > | Pair |
typedef Pair * | iterator |
typedef const Pair * | const_iterator |
Public Member Functions | |
SmallMap () | |
Creates new SmallMap. | |
~SmallMap () | |
Data are freed in SmallVector destructor. | |
const Pair * | Find (const T &key) const |
Finds given key in this map. | |
Pair * | Find (const T &key) |
Finds given key in this map. | |
bool | Contains (const T &key) const |
Tests whether a key is assigned in this map. | |
void | Erase (Pair *pair) |
Removes given pair from this map. | |
bool | Erase (const T &key) |
Removes given key from this map. | |
bool | Insert (const T &key, const U &data) |
Adds new item to this map. | |
U & | operator[] (const T &key) |
Returns data belonging to this key. | |
void | SortByKey () |
Static Public Member Functions | |
static int CDECL | KeySorter (const Pair *a, const Pair *b) |
Implementation of simple mapping class.
Both types have to be POD ("Plain Old Data")! It has inherited accessors from SmallVector().
T | Key type. | |
U | Value type. | |
S | Unit of allocation. |
Definition at line 42 of file smallmap_type.hpp.
Creates new SmallMap.
Data are initialized in SmallVector constructor
Definition at line 48 of file smallmap_type.hpp.
bool SmallMap< T, U, S >::Contains | ( | const T & | key | ) | const [inline] |
Tests whether a key is assigned in this map.
key | key to test |
Definition at line 83 of file smallmap_type.hpp.
Referenced by ScriptInfo::AddLabels(), NewGRFParametersWindow::DrawWidget(), AISettingsWindow::DrawWidget(), GRFParameterInfo::Finalize(), UnmappedChoiceList::Flush(), GamelogPrint(), SmallMap< NetworkAddress, SOCKET, 4 >::Insert(), NetworkAddress::Resolve(), and TranslateTTDPatchCodes().
void SmallMap< T, U, S >::Erase | ( | Pair * | pair | ) | [inline] |
Removes given pair from this map.
pair | pair to remove |
Definition at line 93 of file smallmap_type.hpp.
Referenced by GamelogPrint().
bool SmallMap< T, U, S >::Erase | ( | const T & | key | ) | [inline] |
Removes given key from this map.
key | key to remove |
Definition at line 105 of file smallmap_type.hpp.
Pair* SmallMap< T, U, S >::Find | ( | const T & | key | ) | [inline] |
Finds given key in this map.
key | key to find |
Definition at line 70 of file smallmap_type.hpp.
const Pair* SmallMap< T, U, S >::Find | ( | const T & | key | ) | const [inline] |
Finds given key in this map.
key | key to find |
Definition at line 57 of file smallmap_type.hpp.
Referenced by ChangeGRFParamValueNames(), SmallMap< NetworkAddress, SOCKET, 4 >::Contains(), NewGRFParametersWindow::DrawWidget(), AISettingsWindow::DrawWidget(), GamelogPrint(), Vehicle::GetConsistFreeCapacities(), Window::GetQueryString(), GetRating(), NewGRFParametersWindow::OnClick(), and AISettingsWindow::OnClick().
bool SmallMap< T, U, S >::Insert | ( | const T & | key, | |
const U & | data | |||
) | [inline] |
Adds new item to this map.
key | key | |
data | data |
Definition at line 122 of file smallmap_type.hpp.
Referenced by ScriptInfo::AddLabels(), ChangeGRFParamValueNames(), and GRFParameterInfo::GRFParameterInfo().
U& SmallMap< T, U, S >::operator[] | ( | const T & | key | ) | [inline] |
Returns data belonging to this key.
key | key |
Definition at line 137 of file smallmap_type.hpp.