OpenTTD Source 20241224-master-gf74b0cf984
|
Hand-rolled multimap as map of lists. More...
#include <multimap.hpp>
Public Types | |
typedef std::list< Tvalue > | List |
typedef List::iterator | ListIterator |
typedef List::const_iterator | ConstListIterator |
typedef std::map< Tkey, List, Tcompare > | Map |
typedef Map::iterator | MapIterator |
typedef Map::const_iterator | ConstMapIterator |
typedef MultiMapIterator< MapIterator, ListIterator, Tkey, Tvalue, Tcompare > | iterator |
typedef MultiMapIterator< ConstMapIterator, ConstListIterator, Tkey, const Tvalue, Tcompare > | const_iterator |
Public Member Functions | |
iterator | erase (iterator it) |
Erase the value pointed to by an iterator. | |
void | Insert (const Tkey &key, const Tvalue &val) |
Insert a value at the end of the range with the specified key. | |
size_t | size () const |
Count all items in this MultiMap. | |
size_t | MapSize () const |
Count the number of ranges with equal keys in this MultiMap. | |
std::pair< iterator, iterator > | equal_range (const Tkey &key) |
Get a pair of iterators specifying a range of items with equal keys. | |
std::pair< const_iterator, const_iterator > | equal_range (const Tkey &key) const |
Get a pair of constant iterators specifying a range of items with equal keys. | |
Hand-rolled multimap as map of lists.
Behaves mostly like a list, but is sorted by Tkey so that you can easily look up ranges of equal keys. Those ranges are internally ordered in a deterministic way (contrary to STL multimap). All STL-compatible members are named in STL style, all others are named in OpenTTD style.
Definition at line 281 of file multimap.hpp.
typedef MultiMapIterator<ConstMapIterator, ConstListIterator, Tkey, const Tvalue, Tcompare> MultiMap< Tkey, Tvalue, Tcompare >::const_iterator |
Definition at line 292 of file multimap.hpp.
typedef List::const_iterator MultiMap< Tkey, Tvalue, Tcompare >::ConstListIterator |
Definition at line 285 of file multimap.hpp.
typedef Map::const_iterator MultiMap< Tkey, Tvalue, Tcompare >::ConstMapIterator |
Definition at line 289 of file multimap.hpp.
typedef MultiMapIterator<MapIterator, ListIterator, Tkey, Tvalue, Tcompare> MultiMap< Tkey, Tvalue, Tcompare >::iterator |
Definition at line 291 of file multimap.hpp.
typedef std::list<Tvalue> MultiMap< Tkey, Tvalue, Tcompare >::List |
Definition at line 283 of file multimap.hpp.
typedef List::iterator MultiMap< Tkey, Tvalue, Tcompare >::ListIterator |
Definition at line 284 of file multimap.hpp.
typedef std::map<Tkey, List, Tcompare > MultiMap< Tkey, Tvalue, Tcompare >::Map |
Definition at line 287 of file multimap.hpp.
typedef Map::iterator MultiMap< Tkey, Tvalue, Tcompare >::MapIterator |
Definition at line 288 of file multimap.hpp.
|
inline |
Get a pair of iterators specifying a range of items with equal keys.
key | Key to look for. |
Definition at line 357 of file multimap.hpp.
Referenced by StationCargoList::ShiftCargo().
|
inline |
Get a pair of constant iterators specifying a range of items with equal keys.
key | Key to look for. |
Definition at line 372 of file multimap.hpp.
|
inline |
Erase the value pointed to by an iterator.
The iterator may be invalid afterwards.
it | Iterator pointing at some value. |
Definition at line 299 of file multimap.hpp.
References MultiMapIterator< Tmap_iter, Tlist_iter, Tkey, Tvalue, Tcompare >::list_iter, MultiMapIterator< Tmap_iter, Tlist_iter, Tkey, Tvalue, Tcompare >::list_valid, and MultiMapIterator< Tmap_iter, Tlist_iter, Tkey, Tvalue, Tcompare >::map_iter.
Referenced by StationCargoList::ShiftCargo(), and StationCargoList::Truncate().
|
inline |
Insert a value at the end of the range with the specified key.
key | Key to be inserted at. |
val | Value to be inserted. |
Definition at line 323 of file multimap.hpp.
|
inline |
Count the number of ranges with equal keys in this MultiMap.
Definition at line 347 of file multimap.hpp.
References Map::size.
|
inline |
Count all items in this MultiMap.
This involves iterating over the map.
Definition at line 334 of file multimap.hpp.