]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
getActiveStates: return a sorted, uniqued vector
authorJustin Viiret <justin.viiret@intel.com>
Wed, 8 Mar 2017 04:41:06 +0000 (15:41 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:17:03 +0000 (15:17 +1000)
util/ng_find_matches.cpp

index 0890319d55178d23a47f32cbc21132b99b72f0ea..8c48081f4fe6b90a64e43a90ed787c0cc919b8c0 100644 (file)
@@ -605,8 +605,8 @@ struct StateSet {
     }
 #endif
 
-    flat_set<State> getActiveStates() const {
-        flat_set<State> result;
+    vector<State> getActiveStates() const {
+        vector<State> result;
 
         for (u32 dist = 0; dist <= edit_distance; dist++) {
             // get all shadow vertices (including original graph)
@@ -614,8 +614,8 @@ struct StateSet {
             for (size_t id = cur_shadow_vertices.find_first();
                  id != cur_shadow_vertices.npos;
                  id = cur_shadow_vertices.find_next(id)) {
-                result.emplace(id, dist, shadows_som[dist][id],
-                               State::NODE_SHADOW);
+                result.emplace_back(id, dist, shadows_som[dist][id],
+                                    State::NODE_SHADOW);
             }
 
             // the rest is only valid for edited graphs
@@ -628,11 +628,12 @@ struct StateSet {
             for (size_t id = cur_helper_vertices.find_first();
                  id != cur_helper_vertices.npos;
                  id = cur_helper_vertices.find_next(id)) {
-                result.emplace(id, dist, helpers_som[dist][id],
-                               State::NODE_HELPER);
+                result.emplace_back(id, dist, helpers_som[dist][id],
+                                    State::NODE_HELPER);
             }
         }
 
+        sort_and_unique(result);
         return result;
     }
 
@@ -743,6 +744,11 @@ bool operator<(const StateSet::State &a, const StateSet::State &b) {
     return false;
 }
 
+bool operator==(const StateSet::State &a, const StateSet::State &b) {
+    return a.idx == b.idx && a.level == b.level && a.type == b.type &&
+           a.som == b.som;
+}
+
 struct fmstate {
     const size_t num_states; // number of vertices in graph
     StateSet states; // currently active states