From 55f554eea1c1c5135329ae18ab4f50661ba7c6bf Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 14 Apr 2017 14:31:17 -0700 Subject: Introduce Util::group_by() --- toolsrc/include/vcpkg_Util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h index bb93413ed..978407bd8 100644 --- a/toolsrc/include/vcpkg_Util.h +++ b/toolsrc/include/vcpkg_Util.h @@ -39,4 +39,14 @@ namespace vcpkg::Util { return std::find_if_not(cont.cbegin(), cont.cend(), pred); } + + template + void group_by(const Container& cont, std::map>* output, Func f) + { + for (const V& element : cont) + { + K key = f(element); + (*output)[key].push_back(&element); + } + } } \ No newline at end of file -- cgit v1.2.3