summaryrefslogtreecommitdiff
path: root/src/support/insert_ordered.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/insert_ordered.h')
-rw-r--r--src/support/insert_ordered.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/support/insert_ordered.h b/src/support/insert_ordered.h
index 1460c4329..f39eb61b0 100644
--- a/src/support/insert_ordered.h
+++ b/src/support/insert_ordered.h
@@ -50,12 +50,13 @@ template<typename T> struct InsertOrderedSet {
}
// cheating a bit, not returning the iterator
- void insert(const T& val) {
- auto it = Map.find(val);
- if (it == Map.end()) {
+ bool insert(const T& val) {
+ auto [it, inserted] = Map.insert({val, List.begin()});
+ if (inserted) {
List.push_back(val);
- Map.insert(std::make_pair(val, --List.end()));
+ it->second = --List.end();
}
+ return inserted;
}
size_t size() const { return Map.size(); }