Vcsn  2.2
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 self_t = trie_builder
 
using automaton_t = mutable_automaton< context_t >
 The type of the result. More...
 
using work_automaton_t = std::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 >
 The input labelset, free/letterized or not. More...
 
using letter_t = letter_t_of< context_t >
 
using word_t = word_t_of< context_t >
 
using weightset_t = weightset_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 >
 Polynomialset for the input: weighted words. More...
 
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=weightset_t::one())
 Add a monomial. More...
 
void add (const monomial_t &m)
 Add a monomial. More...
 
void add (const polynomial_t &p)
 Add a polynomial. More...
 
void add_words (std::istream &is)
 Add all the words (one per line) in this stream. More...
 
void add_monomials (std::istream &is)
 Add all the monomials (one per line) in this stream. More...
 
void add (std::istream &is, const std::string &format)
 Add all the monomials in this stream. More...
 
template<direction D = Dir>
auto result () -> std::enable_if_t< D==direction::forward, automaton_t >
 Get the result for the forward trie. More...
 
template<direction D = Dir>
auto result () -> std::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. It is typically a letterset, even though we feed it with words.
Dirif forward build a trie (single initial state) otherwise (backward) build a reversed trie (single final state, but many initial states).

Definition at line 50 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 56 of file trie.hh.

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

Definition at line 53 of file trie.hh.

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

The input labelset, free/letterized or not.

Definition at line 63 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 64 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 73 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 72 of file trie.hh.

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

Polynomialset for the input: weighted words.

Definition at line 71 of file trie.hh.

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

Definition at line 54 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 68 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 67 of file trie.hh.

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

Definition at line 66 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 65 of file trie.hh.

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

The type of the automaton we work on.

Definition at line 61 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 75 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 = weightset_t::one() 
)
inline

Add a monomial.

Parameters
lthe word to add.
wits associated weight.

Definition at line 82 of file trie.hh.

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

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

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 88 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 94 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 ( std::istream &  is,
const std::string &  format 
)
inline

Add all the monomials in this stream.

Definition at line 122 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::add_monomials(), vcsn::detail::trie_builder< Context, Dir >::add_words(), is, and vcsn::detail::map().

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 158 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>
void vcsn::detail::trie_builder< Context, Dir >::add_monomials ( std::istream &  is)
inline

Add all the monomials (one per line) in this stream.

Definition at line 114 of file trie.hh.

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

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_words ( std::istream &  is)
inline

Add all the words (one per line) in this stream.

Definition at line 101 of file trie.hh.

References vcsn::detail::trie_builder< Context, Dir >::add(), vcsn::conv(), vcsn::detail::trie_builder< Context, Dir >::ctx_, vcsn::detail::make_wordset(), and vcsn::detail::quote().

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 174 of file trie.hh.

References vcsn::detail::front(), vcsn::detail::out(), 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 ( ) -> std::enable_if_t<D == direction::forward, automaton_t>
inline

Get the result for the forward trie.

Definition at line 138 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 ( ) -> std::enable_if_t<D == direction::backward, automaton_t>
inline

Get the result for a backward trie.

Definition at line 146 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
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 194 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: