A simple, fixed-size associative array with lookup by key or value.
FlatMaps can be initialized by:
embed:rst:leading-asterisk * .. literalinclude:: examples/flat_map.cc * :language: cpp * :linenos: * :start-after: [pw_containers-flat_map] * :end-before: [pw_containers-flat_map] *
The keys do not need to be sorted as the constructor will sort the items if need be.
Classes | |
| class | mapped_iterator |
Public Types | |
| using | key_type = Key |
| using | mapped_type = Value |
| using | value_type = Pair< key_type, mapped_type > |
| using | pointer = value_type * |
| using | reference = value_type & |
| using | size_type = size_t |
| using | difference_type = ptrdiff_t |
| using | container_type = typename std::array< value_type, kArraySize > |
| using | iterator = typename container_type::iterator |
| using | const_iterator = typename container_type::const_iterator |
Public Member Functions | |
| constexpr | FlatMap (const std::array< value_type, kArraySize > &items) |
| constexpr | FlatMap (std::array< value_type, kArraySize > &&items) |
| template<typename... Items, typename = std::enable_if_t< std::conjunction_v<std::is_same<Items, value_type>...>>> | |
| constexpr | FlatMap (const Items &... items) |
| FlatMap (FlatMap &)=delete | |
| FlatMap & | operator= (FlatMap &)=delete |
| constexpr size_type | size () const |
| constexpr size_type | empty () const |
| constexpr size_type | max_size () const |
| constexpr mapped_type & | at (const key_type &key) |
| constexpr const mapped_type & | at (const key_type &key) const |
| constexpr bool | contains (const key_type &key) const |
| constexpr const_iterator | find (const key_type &key) const |
| constexpr const_iterator | lower_bound (const key_type &key) const |
| constexpr const_iterator | upper_bound (const key_type &key) const |
| constexpr std::pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
| constexpr const_iterator | begin () const |
| constexpr const_iterator | cbegin () const |
| constexpr const_iterator | end () const |
| constexpr const_iterator | cend () const |
| constexpr mapped_iterator | mapped_begin () |
| constexpr mapped_iterator | mapped_end () |