aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index c888c8b8..a9ad2172 100644
--- a/common/util.h
+++ b/common/util.h
@@ -21,6 +21,7 @@
#define UTIL_H
#include <map>
+#include <set>
#include <string>
#include "nextpnr.h"
@@ -65,6 +66,15 @@ template <typename K, typename V> std::map<K, V *> sorted(const std::unordered_m
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)
+{
+ std::set<K> retVal;
+ for (auto &item : orig)
+ retVal.insert(item);
+ return retVal;
+};
+
NEXTPNR_NAMESPACE_END
#endif