#include <digraphx/map_adapter.hpp>
template<typename Container>
MapAdapterBase class
Dict-like data structure by std::vector and Range.
Derived classes
-
template<typename Container>class MapAdapter
- Dict-like data structure by std::vector and Range.
Public types
- using key_type = size_t
- using mapped_type = typename Container::value_type
-
using value_type = std::pair<key_
type, mapped_ type>
Constructors, destructors, conversion operators
- MapAdapterBase(Container& lst) explicit
- Construct a new MapAdapter object.
Public functions
-
auto operator[](const key_
type& key) -> mapped_ type& -
auto operator[](const key_
type& key) const -> const mapped_ type& -
auto at(const key_
type& key) const -> const mapped_ type& -
auto contains(const key_
type& key) const -> bool - auto size() const -> size_t
Public variables
Function documentation
template<typename Container>
MapAdapterBase<Container>:: MapAdapterBase(Container& lst) explicit
Construct a new MapAdapter object.
Parameters | |
---|---|
lst in | The parameter lst is a reference to a container object. |
The function constructs a new MapAdapter object with a given container.
template<typename Container>
mapped_ type& MapAdapterBase<Container>:: operator[](const key_ type& key)
Parameters | |
---|---|
key in | The parameter "key" is of type "key_type", which is a data type that represents the key used to search for an element in the container. |
Returns | The operator[] is returning a reference to the mapped_type value associated with the given key. |
The function overloads the subscript operator to access and modify the value associated with a given key in a map-like container.
template<typename Container>
const mapped_ type& MapAdapterBase<Container>:: operator[](const key_ type& key) const
Parameters | |
---|---|
key in | The parameter "key" is of type "key_type", which is a data type that represents the key used to search for an element in the container. |
Returns | a constant reference to the value associated with the given key in the _lst container. |
The function returns a constant reference to the value associated with the given key in a map-like container.
template<typename Container>
const mapped_ type& MapAdapterBase<Container>:: at(const key_ type& key) const
Returns | a constant reference to the value associated with the given key. |
---|
The function at() returns a constant reference to the value associated with a given key in a map.
template<typename Container>
bool MapAdapterBase<Container>:: contains(const key_ type& key) const
Parameters | |
---|---|
key in | The parameter "key" is of type "key_type", which is a data type that represents the key used to search for an element in the container. |
Returns | a boolean value. It will return true if the key is contained in the data structure, and false otherwise. |
The function checks if a given key is present in a data structure.