getActiveStates: return a sorted, uniqued vector

This commit is contained in:
Justin Viiret 2017-03-08 15:41:06 +11:00 committed by Matthew Barr
parent 79308e6791
commit 7ad21500c4

View 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