16 template <
typename Context>
17 mutable_automaton<Context>
19 const std::vector<unsigned>& finals)
21 using context_t = Context;
22 const auto& ls = *ctx.labelset();
25 "double_ring: the alphabet needs at least 2 letters");
26 auto a = ls.value(letters[0]);
27 auto b = ls.value(letters[1]);
31 automaton_t res = make_shared_ptr<automaton_t>(
ctx);
36 auto p = res->new_state();
44 std::map<unsigned, state_t> states;
49 for (
unsigned i = 1; i < n; ++i)
51 state_t y = res->new_state();
52 res->new_transition(x, y, a);
53 res->new_transition(y, x,
b);
57 res->new_transition(x, p, a);
58 res->new_transition(p, x,
b);
63 require(f < n,
"double_ring: invalid list of finals");
64 res->set_final(states[f]);
75 template <
typename Ctx,
typename,
typename>
78 const std::vector<unsigned>& finals)
80 const auto& c = ctx->as<Ctx>();
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
Provide a variadic mul on top of a binary mul(), and one().
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
std::shared_ptr< detail::automaton_base > automaton
static dyn::context ctx(const driver &d)
Get the context of the driver.
automaton double_ring(const context &ctx, unsigned n, const std::vector< unsigned > &finals)
Bridge.