previousnext
ASTL homeSTL home

Tree_build

 

Prototype

tree_build is actually overloaded, there is in fact to function:
template <class DFA, class InputIterator> 
void tree_build(DFA &dfa, InputIterator start, InputIterator finish);

template <class DFA, class InputIterator>
typename DFA::State 
tree_build(DFA &dfa, InputIterator first, InputIterator last, 
     const typename DFA::Tag &t);

Description

The first function add to dfa, a tree-like automaton, a list of words, a word being a container<alphabet>.

The second one add to dfa, still a tree-like automaton, a single word, setting its tag to t.

Definition

Defined in astl_tree.h.

Requirements on types

Preconditions

dfa must be a tree or empty.

In addition:

Example

CODE
OUTPUT

#include <tag.h>
#include <dfa_matrix.h>
#include <alphabet.h>
#include <language.h>
#include <astl_tree.h>


main()
{
//spécifie the type of the DFA
typedef DFA_matrix<Type_alphabet<char> > DFA_type;
typedef istream_iterator<vector<typename DFA_type::Alphabet> > Entry;

//initialising the DFA, empty

DFA_type dfa;

//creating states and transitions . . .
cout<<"enter words (return to separe, ctr-D to end)"<<endl; tree_build(dfa,Entry(cin),Entry());

//writing the language on the standart output
cout<<"words reconized by your DFA"<<endl;
language(dfa,ostream_iterator<DFA_type::Alphabet>(cout));

}

# ./tree
enter words (return to separe, ctr-D to end)
stl
astl
template
iterator
input iterator
container
function
function object
functor

words reconized by your DFA
astl
container
function
function object
functor
input iterator
iterator
stl
template

Notes

See also