From 518ead2e2dd11ba3bcd19085c2c91178ba9e458c Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 12 Oct 2020 11:41:26 +0100 Subject: nexus: IO pre-packing Signed-off-by: David Shah --- common/util.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/util.h b/common/util.h index 9512bd40..d82e984a 100644 --- a/common/util.h +++ b/common/util.h @@ -112,6 +112,15 @@ template std::map sorted(const std::unordered_m return retVal; }; +// Wrap an unordered_map, and allow it to be iterated over sorted by key +template std::map sorted_ref(std::unordered_map &orig) +{ + std::map retVal; + for (auto &item : orig) + retVal.emplace(std::make_pair(item.first, std::ref(item.second))); + return retVal; +}; + // Wrap an unordered_set, and allow it to be iterated over sorted by key template std::set sorted(const std::unordered_set &orig) { -- cgit v1.2.3