Vcsn  2.1
Be Rational
vcsn::detail::trie_builder< Context, Dir > Class Template Reference

Build a trie automaton (prefix-tree-like automaton). More...

#include <trie.hh>

Collaboration diagram for vcsn::detail::trie_builder< Context, Dir >:

Public Types

using context_t = Context
 
using automaton_t = mutable_automaton< context_t >
 The type of the result. More...
 
using work_automaton_t = conditional_t< Dir==direction::forward, automaton_t, transpose_automaton< automaton_t >>
 The type of the automaton we work on. More...
 
using labelset_t = labelset_t_of< context_t >
 
using letter_t = letter_t_of< context_t >
 
using word_t = word_t_of< context_t >
 
using weight_t = weight_t_of< context_t >
 
using state_t = state_t_of< automaton_t >
 
using polynomialset_t = word_polynomialset_t< context_t >
 
using polynomial_t = typename polynomialset_t::value_t
 
using monomial_t = typename polynomialset_t::monomial_t
 

Public Member Functions

 trie_builder (const context_t &c)
 
void add (const word_t &l, const weight_t &w)
 Add a monomial. More...
 
void add (const monomial_t &m)
 Add a monomial. More...
 
void add (const polynomial_t &p)
 Add a polynomial. More...
 
template<direction D = Dir>
auto result () -> enable_if_t< D==direction::forward, automaton_t >
 Get the result for the forward trie. More...
 
template<direction D = Dir>
auto result () -> enable_if_t< D==direction::backward, automaton_t >
 Get the result for a backward trie. More...
 

Private Member Functions

void add_ (const word_t &lbl, const weight_t &wgt)
 Add a monomial. More...
 
state_t next_ (state_t s, letter_t l)
 Follow a transition, possibly creating it. More...
 

Private Attributes

work_automaton_t res_
 The automaton being built. More...
 
const context_tctx_ = res_->context()
 The context of the automaton: letterized. More...
 
letterized_t< labelset_t >::value_t padding_ = letterized_t<labelset_t>::one()
 Padding, in case it is needed. More...
 

Detailed Description

template<typename Context, direction Dir>
class vcsn::detail::trie_builder< Context, Dir >

Build a trie automaton (prefix-tree-like automaton).

Template Parameters
Contextthe context of the mutable_automaton to build.
Dirif forward build a trie (single initial state) otherwise (backward) build a reversed trie (single final state, but many initial states).

Definition at line 30 of file trie.hh.

Member Typedef Documentation

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::automaton_t = mutable_automaton<context_t>

The type of the result.

Definition at line 35 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::context_t = Context

Definition at line 33 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::labelset_t = labelset_t_of<context_t>

Definition at line 41 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::letter_t = letter_t_of<context_t>

Definition at line 42 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::monomial_t = typename polynomialset_t::monomial_t

Definition at line 48 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::polynomial_t = typename polynomialset_t::value_t

Definition at line 47 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::polynomialset_t = word_polynomialset_t<context_t>

Definition at line 46 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::state_t = state_t_of<automaton_t>

Definition at line 45 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::weight_t = weight_t_of<context_t>

Definition at line 44 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::word_t = word_t_of<context_t>

Definition at line 43 of file trie.hh.

template<typename Context , direction Dir>
using vcsn::detail::trie_builder< Context, Dir >::work_automaton_t = conditional_t<Dir == direction::forward, automaton_t, transpose_automaton<automaton_t>>

The type of the automaton we work on.

Definition at line 40 of file trie.hh.

Constructor & Destructor Documentation

template<typename Context , direction Dir>
vcsn::detail::trie_builder< Context, Dir >::trie_builder ( const context_t c)
inline

Definition at line 50 of file trie.hh.

Member Function Documentation

template<typename Context , direction Dir>
void vcsn::detail::trie_builder< Context, Dir >::add ( const word_t l,
const weight_t w 
)
inline

Add a monomial.

Parameters
lthe word to add.
wits associated weight.

Definition at line 57 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::add_().

Referenced by vcsn::detail::trie_builder< Context, Dir >::add().

Here is the call graph for this function:

template<typename Context , direction Dir>
void vcsn::detail::trie_builder< Context, Dir >::add ( const monomial_t m)
inline

Add a monomial.

Definition at line 63 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::label_of(), and vcsn::weight_of().

Here is the call graph for this function:

template<typename Context , direction Dir>
void vcsn::detail::trie_builder< Context, Dir >::add ( const polynomial_t p)
inline

Add a polynomial.

Definition at line 69 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::add().

Here is the call graph for this function:

template<typename Context , direction Dir>
void vcsn::detail::trie_builder< Context, Dir >::add_ ( const word_t lbl,
const weight_t wgt 
)
inlineprivate

Add a monomial.

Take the direction into account (i.e., transpose the word if needed).

Parameters
lblthe word to add.
wgtits associated weight.

Definition at line 97 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::ctx_, vcsn::forward, vcsn::detail::trie_builder< Context, Dir >::next_(), vcsn::detail::trie_builder< Context, Dir >::padding_, and vcsn::detail::trie_builder< Context, Dir >::res_.

Referenced by vcsn::detail::trie_builder< Context, Dir >::add().

Here is the call graph for this function:

template<typename Context , direction Dir>
state_t vcsn::detail::trie_builder< Context, Dir >::next_ ( state_t  s,
letter_t  l 
)
inlineprivate

Follow a transition, possibly creating it.

Returns
the destination state.

Definition at line 113 of file trie.hh.

References vcsn::detail::front(), and vcsn::detail::trie_builder< Context, Dir >::res_.

Referenced by vcsn::detail::trie_builder< Context, Dir >::add_().

Here is the call graph for this function:

template<typename Context , direction Dir>
template<direction D = Dir>
auto vcsn::detail::trie_builder< Context, Dir >::result ( ) -> enable_if_t<D == direction::forward, automaton_t>
inline

Get the result for the forward trie.

Definition at line 77 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::res_.

template<typename Context , direction Dir>
template<direction D = Dir>
auto vcsn::detail::trie_builder< Context, Dir >::result ( ) -> enable_if_t<D == direction::backward, automaton_t>
inline

Get the result for a backward trie.

Definition at line 85 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::res_, and vcsn::transpose().

Here is the call graph for this function:

Member Data Documentation

template<typename Context , direction Dir>
const context_t& vcsn::detail::trie_builder< Context, Dir >::ctx_ = res_->context()
private

The context of the automaton: letterized.

Definition at line 130 of file trie.hh.

Referenced by vcsn::detail::trie_builder< Context, Dir >::add_().

template<typename Context , direction Dir>
letterized_t<labelset_t>::value_t vcsn::detail::trie_builder< Context, Dir >::padding_ = letterized_t<labelset_t>::one()
private

Padding, in case it is needed.

Definition at line 133 of file trie.hh.

Referenced by vcsn::detail::trie_builder< Context, Dir >::add_().

template<typename Context , direction Dir>
work_automaton_t vcsn::detail::trie_builder< Context, Dir >::res_
private

The documentation for this class was generated from the following file: