|
OpenTTD
|
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 () |
Public Member Functions inherited from SmallVector< SmallPair< T, U >, S > | |
| SmallVector (const SmallVector &other) | |
| Copy constructor. | |
| SmallVector (const SmallVector< SmallPair< T, U >, X > &other) | |
| Generic copy constructor. | |
| SmallVector & | operator= (const SmallVector &other) |
| Assignment. | |
| SmallVector & | operator= (const SmallVector< SmallPair< T, U >, X > &other) |
| Generic assignment. | |
| void | Assign (const SmallVector< SmallPair< T, U >, X > &other) |
| Assign items from other vector. | |
| void | Clear () |
| Remove all items from the list. | |
| void | Reset () |
| Remove all items from the list and free allocated memory. | |
| void | Compact () |
| Compact the list down to the smallest block size boundary. | |
| SmallPair< T, U > * | Append (uint to_add=1) |
| Append an item and return it. | |
| void | Resize (uint num_items) |
| Set the size of the vector, effectively truncating items from the end or appending uninitialised ones. | |
| const SmallPair< T, U > * | Find (const SmallPair< T, U > &item) const |
| Search for the first occurrence of an item. | |
| SmallPair< T, U > * | Find (const SmallPair< T, U > &item) |
| Search for the first occurrence of an item. | |
| int | FindIndex (const SmallPair< T, U > &item) const |
| Search for the first occurrence of an item. | |
| bool | Contains (const SmallPair< T, U > &item) const |
| Tests whether a item is present in the vector. | |
| void | Erase (SmallPair< T, U > *item) |
| Removes given item from this vector. | |
| void | ErasePreservingOrder (uint pos, uint count=1) |
| Remove items from the vector while preserving the order of other items. | |
| bool | Include (const SmallPair< T, U > &item) |
| Tests whether a item is present in the vector, and appends it to the end if not. | |
| uint | Length () const |
| Get the number of items in the list. | |
| const SmallPair< T, U > * | Begin () const |
| Get the pointer to the first item (const) | |
| SmallPair< T, U > * | Begin () |
| Get the pointer to the first item. | |
| const SmallPair< T, U > * | End () const |
| Get the pointer behind the last valid item (const) | |
| SmallPair< T, U > * | End () |
| Get the pointer behind the last valid item. | |
| const SmallPair< T, U > * | Get (uint index) const |
| Get the pointer to item "number" (const) | |
| SmallPair< T, U > * | Get (uint index) |
| Get the pointer to item "number". | |
| const SmallPair< T, U > & | operator[] (uint index) const |
| Get item "number" (const) | |
| SmallPair< T, U > & | operator[] (uint index) |
| Get item "number". | |
Static Public Member Functions | |
| static int CDECL | KeySorter (const Pair *a, const Pair *b) |
Additional Inherited Members | |
Protected Attributes inherited from SmallVector< SmallPair< T, U >, S > | |
| SmallPair< T, U > * | data |
| The pointer to the first item. | |
| uint | items |
| The number of items stored. | |
| uint | capacity |
| The available space for storing items. | |
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.
|
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(), GetLayouter(), SmallMap< NetworkAddress, SOCKET, 4 >::Insert(), SpriteAlignerWindow::OnClick(), NetworkAddress::Resolve(), and TranslateTTDPatchCodes().
Removes given pair from this map.
| pair | pair to remove |
Definition at line 93 of file smallmap_type.hpp.
Referenced by GamelogPrint(), and SpriteAlignerWindow::OnClick().
|
inline |
Removes given key from this map.
| key | key to remove |
Definition at line 105 of file smallmap_type.hpp.
|
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(), Layouter::GetFont(), FreeTypeFontCache::GetFontTable(), Window::GetQueryString(), GetRating(), NewGRFParametersWindow::OnClick(), AISettingsWindow::OnClick(), and SpriteAlignerWindow::SetStringParameters().
|
inline |
Finds given key in this map.
| key | key to find |
Definition at line 70 of file smallmap_type.hpp.
|
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(), FreeTypeFontCache::GetFontTable(), GetLayouter(), GRFParameterInfo::GRFParameterInfo(), and SpriteAlignerWindow::OnClick().
|
inline |
Returns data belonging to this key.
| key | key |
Definition at line 137 of file smallmap_type.hpp.
1.8.1.2