mirror of https://github.com/microsoft/vcpkg.git
Introduce Util::group_by()
This commit is contained in:
parent
392b3a50ea
commit
55f554eea1
|
|
@ -39,4 +39,14 @@ namespace vcpkg::Util
|
|||
{
|
||||
return std::find_if_not(cont.cbegin(), cont.cend(), pred);
|
||||
}
|
||||
|
||||
template<class K, class V, class Container, class Func>
|
||||
void group_by(const Container& cont, std::map<K, std::vector<const V*>>* output, Func f)
|
||||
{
|
||||
for (const V& element : cont)
|
||||
{
|
||||
K key = f(element);
|
||||
(*output)[key].push_back(&element);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue