Skip to content

Commit

Permalink
transitions: revert storage to vector instead of uset
Browse files Browse the repository at this point in the history
  • Loading branch information
nightly committed Aug 18, 2023
1 parent 0c3db90 commit 86fc8a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/lts/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

#include "lts/transition.h"

#include <ankerl/unordered_dense.h>
#include <vector>

namespace nightly {

template <typename KeyT = std::string, typename TransitionT = std::string>
class State {
public:
ankerl::unordered_dense::set<Transition<KeyT, TransitionT>> transitions_;
std::vector<Transition<KeyT, TransitionT>> transitions_;
public:

/**
Expand All @@ -25,20 +25,25 @@ namespace nightly {
State() = default;
~State() = default;

ankerl::unordered_dense::set<Transition<KeyT, TransitionT>>& transitions() {
std::vector<Transition<KeyT, TransitionT>>& transitions() {
return transitions_;
}

const ankerl::unordered_dense::set<Transition<KeyT, TransitionT>>& transitions() const {
const std::vector<Transition<KeyT, TransitionT>>& transitions() const {
return transitions_;
}

void AddTransition(const TransitionT& label, const KeyT& end_state) {
transitions_.emplace(label, end_state);
transitions_.emplace_back(label, end_state);
}

bool TransitionExists(const TransitionT& label, const KeyT& end_state) const {
return transitions_.contains(Transition(label, end_state));
for (const auto& t : transitions_) {
if ((t.first == label) && (t.second == end_state)) {
return true;
}
}
return false;
}

bool IsEmpty() const {
Expand Down
3 changes: 1 addition & 2 deletions tests/lts/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include "lts/writers/writers.h"
#include "lts/writers/styling.h"

// This is non-deterministic with unordered set
TEST(LTS, DISABLED_FinalStates) {
TEST(LTS, FinalStates) {
nightly::LTS<std::string, std::string, std::hash<std::string>> got;
got.set_initial_state("s0");
got.AddTransition("s0", "a1", "s1");
Expand Down

0 comments on commit 86fc8a9

Please sign in to comment.