MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / GroupChildrenByKey

Function GroupChildrenByKey

CppCoverage/CoverageDataMerger.cpp:52–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 //---------------------------------------------------------------------
51 template <typename Object, typename Key, typename Child>
52 std::map<Key, std::vector<Child*>> GroupChildrenByKey(
53 const std::vector<Object>& collection,
54 const std::function<const std::vector<std::unique_ptr<Child>>& (const Object&)>& getChildren,
55 const std::function<const Key& (const Child&)>& getKey)
56 {
57 std::map<Key, std::vector<Child*>> childrenByKey;
58
59 for (const auto& object : collection)
60 {
61 for (const auto& child : getChildren(object))
62 {
63 const auto& key = getKey(*child);
64
65 childrenByKey[key].push_back(child.get());
66 }
67 }
68
69 return childrenByKey;
70 }
71
72 //---------------------------------------------------------------------
73 void AddFileCoverageTo(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected