vcpkg/toolsrc/include/vcpkg_Maps.h

42 lines
1003 B
C
Raw Normal View History

2016-09-23 14:28:14 +08:00
#pragma once
#include <unordered_map>
#include <unordered_set>
#include <map>
2016-09-23 14:28:14 +08:00
namespace vcpkg { namespace Maps
{
template <typename K, typename V>
std::unordered_set<K> extract_key_set(const std::unordered_map<K, V>& input_map)
{
std::unordered_set<K> key_set;
for (auto const& element : input_map)
{
key_set.insert(element.first);
}
return key_set;
}
2016-11-03 10:33:11 +08:00
template <typename K, typename V>
std::vector<K> extract_keys(const std::unordered_map<K, V>& input_map)
{
std::vector<K> key_set;
for (auto const& element : input_map)
{
key_set.push_back(element.first);
}
return key_set;
}
template <typename K, typename V>
std::vector<K> extract_keys(const std::map<K, V>& input_map)
{
std::vector<K> key_set;
for (auto const& element : input_map)
{
key_set.push_back(element.first);
}
return key_set;
}
2016-09-23 14:28:14 +08:00
}}