diff options
author | David Shah <dave@ds0.me> | 2020-10-12 11:41:26 +0100 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2020-11-30 08:45:27 +0000 |
commit | 518ead2e2dd11ba3bcd19085c2c91178ba9e458c (patch) | |
tree | a72fa90ff7db0a19ed383349166a78d32a7c700e /common | |
parent | 69b449c8759efa15f52add21b1c7f6dc1ceada3a (diff) | |
download | nextpnr-518ead2e2dd11ba3bcd19085c2c91178ba9e458c.tar.gz nextpnr-518ead2e2dd11ba3bcd19085c2c91178ba9e458c.tar.bz2 nextpnr-518ead2e2dd11ba3bcd19085c2c91178ba9e458c.zip |
nexus: IO pre-packing
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r-- | common/util.h | 9 |
1 files changed, 9 insertions, 0 deletions
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 <typename K, typename V> std::map<K, V *> sorted(const std::unordered_m return retVal; }; +// Wrap an unordered_map, and allow it to be iterated over sorted by key +template <typename K, typename V> std::map<K, V &> sorted_ref(std::unordered_map<K, V> &orig) +{ + std::map<K, V &> 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 <typename K> std::set<K> sorted(const std::unordered_set<K> &orig) { |