|
CeresEngine 0.2.0
A game development framework
|
FlatMap is an almsot drop-in replacement of Map.
More...
#include <CeresEngine/Foundation/Container/FlatMap.hpp>
Classes | |
| struct | pair_compare |
Public Types | |
| using | key_type = Key |
| using | mapped_type = T |
| using | value_type = std::pair< Key, T > |
| using | container_type = Container |
| using | key_compare = Compare |
| using | reference = value_type & |
| using | const_reference = const value_type & |
| using | allocator_type = typename container_type::allocator_type |
| using | pointer = typename std::allocator_traits< allocator_type >::pointer |
| using | const_pointer = typename std::allocator_traits< allocator_type >::pointer |
| using | iterator = typename container_type::iterator |
| using | const_iterator = typename container_type::const_iterator |
| using | reverse_iterator = typename container_type::reverse_iterator |
| using | const_reverse_iterator = typename container_type::const_reverse_iterator |
| using | difference_type = typename container_type::difference_type |
| using | size_type = typename container_type::size_type |
Private Attributes | |
| pair_compare | m_cmp |
| container_type | m_container |
FlatMap is an almsot drop-in replacement of Map.
Flat map has an optional underlying container which by default is Vector. Thus the items in the map are in a continuous block of memory. Thus iterating over the map is cache friendly, at the cost of O(n) for insert and erase.
The elements inside (like in Map ) are kept in an order sorted by key. Getting a value by key is O(log2 n). It generally performs much faster than Map for smaller sets of elements.
The difference with Map, which makes FlatMap an not-exactly-drop-in replacement is the last template argument:
Map has <Key, Value, Compare, Allocator>FlatMap has <Key, Value, Compare, Container>The container must be an Vector compatible type (SmallVector is, for example, viable). The container value type must be Pair<Key, Value>.
Changing the allocator.
If you want to change the allocator of flat map, you'll have to provide a container with the appropriate one. Example:
FlatMap< String, Int32, std::less<String>, Vector<Pair<String, Int>, MyAllocator>
myMap
| using CeresEngine::FlatMap< Key, T, Compare, Container >::allocator_type = typename container_type::allocator_type |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::const_iterator = typename container_type::const_iterator |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::const_pointer = typename std::allocator_traits<allocator_type>::pointer |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::const_reference = const value_type& |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::const_reverse_iterator = typename container_type::const_reverse_iterator |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::container_type = Container |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::difference_type = typename container_type::difference_type |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::iterator = typename container_type::iterator |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::key_compare = Compare |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::key_type = Key |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::mapped_type = T |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::pointer = typename std::allocator_traits<allocator_type>::pointer |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::reference = value_type& |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::reverse_iterator = typename container_type::reverse_iterator |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::size_type = typename container_type::size_type |
| using CeresEngine::FlatMap< Key, T, Compare, Container >::value_type = std::pair<Key, T> |
|
inline |
|
inlineexplicit |
|
default |
|
default |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inline |
|
private |
|
private |