Skip to content
Snippets Groups Projects
Commit 2dac8480 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add get_keys() and get_values() for std::map

parent 9c6aa5de
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,7 @@ SET(INCLUDES
algorithm/for_each_if.h
algorithm/apply.hpp
algorithm/get_map_keys_values.h
color/cmaps/colormaps.h
color/cmaps/Named.h
......
......@@ -3,3 +3,4 @@
// This file is generated!
#include "algorithm/for_each_if.h"
#include "algorithm/get_map_keys_values.h"
#include <map>
#include <vector>
namespace simox
{
template <typename K, typename V>
std::vector<K> get_keys(const std::map<K, V>& map)
{
std::vector<K> keys;
keys.reserve(map.size());
for (const auto& [k, v] : map)
{
keys.push_back(k);
}
return keys;
}
template <typename K, typename V>
std::vector<V> get_values(const std::map<K, V>& map)
{
std::vector<V> values;
values.reserve(map.size());
for (const auto& [k, v] : map)
{
values.push_back(v);
}
return values;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment