Keyple Util C++ Library 2.0.0
Reference Terminal Reader API for C++
MapUtils.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
13#pragma once
14
15#include <map>
16#include <vector>
17
18namespace keyple {
19namespace core {
20namespace util {
21namespace cpp {
22
24
25class MapUtils {
26public:
27 template <typename K, typename V>
28 static const std::vector<K> getKeySet(const std::map<const K, const V>& m)
29 {
30 std::vector<K> v;
31
32 for (const auto& e : m) {
33 v.push_back(e.first);
34 }
35
36 return v;
37 }
38
39 template <typename K, typename V>
40 static const std::vector<V> getValueSet(const std::map<const K, const V>& m)
41 {
42 std::vector<V> v;
43
44 for (const auto& e : m) {
45 v.push_back(e.second);
46 }
47
48 return v;
49 }
50};
51
52}
53}
54}
55}
static const std::vector< K > getKeySet(const std::map< const K, const V > &m)
Definition: MapUtils.h:28
static const std::vector< V > getValueSet(const std::map< const K, const V > &m)
Definition: MapUtils.h:40