diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2020-11-30 10:56:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 10:56:59 +0100 |
commit | 8b5c0dc1e49b692b0bb598a90034c27db653622d (patch) | |
tree | afd13c654df1faa0b5df9f11be74eede087fa564 /common/util.h | |
parent | 1afa494e69e3c8af3dd5d1685b9cd2b1d3bea4d0 (diff) | |
parent | 2fe8bebc6ce464afadef2403a8331031e16c5a5d (diff) | |
download | nextpnr-8b5c0dc1e49b692b0bb598a90034c27db653622d.tar.gz nextpnr-8b5c0dc1e49b692b0bb598a90034c27db653622d.tar.bz2 nextpnr-8b5c0dc1e49b692b0bb598a90034c27db653622d.zip |
Merge pull request #524 from daveshah1/nextpnr-nexus
Upstreaming basic support for Nexus devices
Diffstat (limited to 'common/util.h')
-rw-r--r-- | common/util.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h index 9512bd40..07ebac75 100644 --- a/common/util.h +++ b/common/util.h @@ -112,6 +112,24 @@ 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_map, and allow it to be iterated over sorted by key +template <typename K, typename V> std::map<K, const V &> sorted_cref(const std::unordered_map<K, V> &orig) +{ + std::map<K, const 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) { |