Commit eab3464e authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

Add TransitionIterator.

All transition iterators were quickly tested for listg & bmig.

* include/vaucanson/automata/implementation/iterators/transition_iterator.hh,
* include/vaucanson/automata/implementation/iterators/transition_iterator.hxx:
New.  Interface & implementation.
parent 8c84347a
2009-09-16 d-halluin <d-halluin@lrde.epita.fr>
Add TransitionIterator.
All transition iterators were quickly tested for listg & bmig.
* include/vaucanson/automata/implementation/iterators/transition_iterator.hh,
* include/vaucanson/automata/implementation/iterators/transition_iterator.hxx:
New. Interface & implementation.
2009-09-16 d-halluin <d-halluin@lrde.epita.fr>
 
Cosmetic fixes.
......
// transition_iterator.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HH
# include <vaucanson/automata/implementation/iterators/transition_iterator_base.hh>
namespace vcsn
{
template <typename T>
struct TransitionIterator;
/**
* Iterator traits.
*/
template <typename T>
struct iterator_traits_<TransitionIterator<T> >
: iterator_traits_<TransitionIteratorBase<TransitionIterator<T> > >
{
typedef T graph_t;
typedef typename graph_t::htransition_t value_type;
};
/**
* Class for iterators on the successors of a given state.
*/
template <typename T>
struct TransitionIterator
: TransitionIteratorBase<TransitionIterator<T> >
{
/// Self type definition.
typedef TransitionIterator<T> self_t;
typedef typename TransitionIteratorBase<self_t>::graph_t graph_t;
// Typedefs
typedef typename graph_t::htransition_t htransition_t;
typedef typename graph_t::hstate_t hstate_t;
typedef typename graph_t::label_t label_t;
typedef typename graph_t::semiring_elt_value_t semiring_elt_value_t;
TransitionIterator(const graph_t& graph);
~TransitionIterator();
void op_next();
bool op_done() const;
htransition_t op_operator_star() const;
hstate_t op_src() const;
hstate_t op_dst() const;
semiring_elt_value_t op_weight() const;
label_t op_label() const;
private:
typename graph_t::edges_t::iterator i_;
typename graph_t::edges_t::iterator end_;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/transition_iterator.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HH
// transition_iterator.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HXX
# include <vaucanson/automata/implementation/iterators/transition_iterator.hh>
namespace vcsn
{
template <typename T>
TransitionIterator<T>::TransitionIterator(const graph_t& graph)
: TransitionIteratorBase<self_t>(graph),
i_(graph.edges().begin()),
end_(graph.edges().end())
{
}
template <typename T>
TransitionIterator<T>::~TransitionIterator()
{}
template <typename T>
typename TransitionIterator<T>::hstate_t
TransitionIterator<T>::op_src() const
{
// this-> seems to be necessary here.
return this->graph_.src_of(*i_);
}
template <typename T>
typename TransitionIterator<T>::hstate_t
TransitionIterator<T>::op_dst() const
{
return this->graph_.dst_of(*i_);
}
template <typename T>
typename TransitionIterator<T>::semiring_elt_value_t
TransitionIterator<T>::op_weight() const
{
// FIXME: Extract weight from graph::label_t.
return semiring_elt_value_t();
}
template <typename T>
typename TransitionIterator<T>::label_t
TransitionIterator<T>::op_label() const
{
// Note: Should not include the weight.
return this->graph_.label_of(*i_);
}
template <typename T>
void
TransitionIterator<T>::op_next()
{
++i_;
}
template <typename T>
bool
TransitionIterator<T>::op_done() const
{
return i_ == end_;
}
template <typename T>
typename TransitionIterator<T>::htransition_t
TransitionIterator<T>::op_operator_star() const
{
return *i_;
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_HXX
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment