25template <
typename Key,
typename Value>
26class Map :
public std::map<Key, Value> {
47 keys.reserve(map_type::size());
48 for (
const auto& pair : *
this) {
49 keys.push_back(pair.first);
64 values.reserve(map_type::size());
65 for (
const auto& pair : *
this) {
66 values.push_back(pair.second);
82 return map_type::count(key) > 0;
96 for (
const auto& pair : *
this) {
97 if (pair.second == value) {
111 for (
const auto& pair : *
this) {
112 total += pair.second;
125 for (
const auto& pair : *
this) {
126 std::cout << pair.first <<
": " << pair.second <<
'\n';
139 std::stringstream ss = std::stringstream(
"");
142 for (
const auto& pair : *
this) {
146 ss << pair.first <<
": ";
148 static_cast<long double>(pair.second);
151 catch (
const std::exception& e) {
A map.
Definition map.h:26
typename map_type::key_type key_type
Type of the key.
Definition map.h:31
typename map_type::value_type value_type
Type of the value.
Definition map.h:35
Vector< key_type > get_keys() const
Gets the keys.
Definition map.h:45
void print() const
Prints this object.
Definition map.h:124
mapped_type sumValues() const
Calculates the sum of all values in the map.
Definition map.h:109
Vector< mapped_type > get_values() const
Gets the values.
Definition map.h:62
std::string toString() const
Convert this object into a string representation.
Definition map.h:138
std::map< Key, Value > map_type
Type of the map.
Definition map.h:29
typename map_type::mapped_type mapped_type
Type of the mapped.
Definition map.h:33
bool is_key(const key_type &key) const
Query if 'key' is key.
Definition map.h:81
bool is_value(const mapped_type &value) const
Query if 'value' is value.
Definition map.h:95
A vector.
Definition vector.h:24
::value std::string thousandSeparator(T n, int decimals=3)
Convert a plain numeric value to thousand separated value.
Definition utils.h:135