File indexing completed on 2026-06-02 08:51:49
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef MAP_UTILS_H
0009 #define MAP_UTILS_H
0010
0011 #include <map>
0012 #include <vector>
0013
0014 #include "VectorUtils.h"
0015
0016 namespace PARTONS {
0017
0018
0019 class MapUtils {
0020 public:
0021 template<typename Key, typename Value>
0022 static std::vector<Key> intersectionOfKey(const std::map<Key, Value> & lhs,
0023 const std::map<Key, Value> & rhs) {
0024
0025 std::vector<Key> lhsKey = MapUtils::mapToVectorOfKey(lhs);
0026 std::vector<Key> rhsKey = MapUtils::mapToVectorOfKey(rhs);
0027
0028 return VectorUtils::intersection(lhsKey, rhsKey);
0029 }
0030
0031 template<typename Key, typename Value>
0032 static std::vector<Key> mapToVectorOfKey(const std::map<Key, Value> & map) {
0033 std::vector<Key> keys;
0034
0035 typename std::map<Key, Value>::const_iterator it;
0036
0037 for (it = map.begin(); it != map.end(); it++) {
0038 keys.push_back(it->first);
0039 }
0040
0041 return keys;
0042 }
0043 };
0044
0045 }
0046
0047 #endif