14 template <
typename Context>
15 mutable_automaton<Context>
17 const std::vector<unsigned>& finals)
19 using context_t = Context;
20 const auto& ls = *ctx.labelset();
23 "double_ring: the alphabet needs at least 2 letters");
24 auto a = ls.value(letters[0]);
25 auto b = ls.value(letters[1]);
29 automaton_t
res = make_shared_ptr<automaton_t>(
ctx);
34 auto p = res->new_state();
42 std::map<unsigned, state_t> states;
47 for (
unsigned i = 1; i < n; ++i)
49 state_t y = res->new_state();
50 res->new_transition(x, y, a);
51 res->new_transition(y, x,
b);
55 res->new_transition(x, p, a);
56 res->new_transition(p, x,
b);
61 require(f < n,
"double_ring: invalid list of finals");
62 res->set_final(states[f]);
73 template <
typename Ctx,
typename,
typename>
76 const std::vector<unsigned>& finals)
78 const auto& c = ctx->
as<Ctx>();
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
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.
auto & as()
Downcast to the exact type.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
Template-less root for contexts.
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
automaton double_ring(const context &ctx, unsigned n, const std::vector< unsigned > &finals)
Bridge.
Provide a variadic mul on top of a binary mul(), and one().