Commit 16f4f683 authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

Add state iterators.

* include/Makefile.am: Add new files.
* include/vaucanson/automata/implementation/iterators/state_iterator.hh,
* include/vaucanson/automata/implementation/iterators/state_iterator.hxx,
* include/vaucanson/automata/implementation/iterators/state_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/state_iterator_base.hxx:
New. Interface & implementation.
parent 014587e8
2009-09-17 d-halluin <d-halluin@lrde.epita.fr>
Add state iterators.
* include/Makefile.am: Add new files.
* include/vaucanson/automata/implementation/iterators/state_iterator.hh,
* include/vaucanson/automata/implementation/iterators/state_iterator.hxx,
* include/vaucanson/automata/implementation/iterators/state_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/state_iterator_base.hxx:
New. Interface & implementation.
2009-09-17 d-halluin <d-halluin@lrde.epita.fr>
 
Remove inheritance for iterator traits.
......
......@@ -516,14 +516,20 @@ vaucanson/automata/implementation/listg_graph_impl.hh \
vaucanson/automata/implementation/listg_graph_impl.hxx \
vaucanson/automata/implementation/kind_adapter.hh \
vaucanson/automata/implementation/kind_adapter.hxx \
vaucanson/automata/implementation/iterators/delta_transition_iterator.hh \
vaucanson/automata/implementation/iterators/delta_transition_iterator.hxx \
vaucanson/automata/implementation/iterators/delta_transition_iterator.hh \
vaucanson/automata/implementation/iterators/delta_transition_iterator.hxx \
vaucanson/automata/implementation/iterators/iterator_base.hh \
vaucanson/automata/implementation/iterators/iterator_base.hxx \
vaucanson/automata/implementation/iterators/rdelta_transition_iterator.hh \
vaucanson/automata/implementation/iterators/rdelta_transition_iterator.hh \
vaucanson/automata/implementation/iterators/rdelta_transition_iterator.hxx \
vaucanson/automata/implementation/iterators/transition_iterator_base.hh \
vaucanson/automata/implementation/iterators/transition_iterator_base.hxx \
vaucanson/automata/implementation/iterators/transition_iterator_base.hxx \
vaucanson/automata/implementation/iterators/transition_iterator.hh \
vaucanson/automata/implementation/iterators/transition_iterator.hxx \
vaucanson/automata/implementation/iterators/state_iterator_base.hh \
vaucanson/automata/implementation/iterators/state_iterator_base.hxx \
vaucanson/automata/implementation/iterators/state_iterator.hh \
vaucanson/automata/implementation/iterators/state_iterator.hxx \
vaucanson/automata/implementation/transpose_view.hh \
vaucanson/automata/implementation/transpose_view.hxx
......
// state_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_STATE_ITERATOR_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_HH
# include <vaucanson/automata/implementation/iterators/state_iterator_base.hh>
namespace vcsn
{
template <typename T>
struct StateIterator;
/**
* Iterator traits.
*/
template <typename T>
struct iterator_traits_<StateIterator<T> >
{
typedef T graph_t;
typedef typename graph_t::hstate_t value_type;
};
/**
* Class for iterators on the successors of a given state.
*/
template <typename T>
struct StateIterator
: StateIteratorBase<StateIterator<T> >
{
/// Self type definition.
typedef StateIterator<T> self_t;
typedef typename StateIteratorBase<self_t>::graph_t graph_t;
// Typedefs
typedef typename graph_t::hstate_t hstate_t;
StateIterator(const graph_t& graph);
~StateIterator();
void op_next();
bool op_done() const;
hstate_t op_operator_star() const;
private:
typename graph_t::states_t::iterator i_;
typename graph_t::states_t::iterator end_;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/state_iterator.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_HH
// state_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_STATE_ITERATOR_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_HXX
# include <vaucanson/automata/implementation/iterators/state_iterator.hh>
namespace vcsn
{
template <typename T>
StateIterator<T>::StateIterator(const graph_t& graph)
: StateIteratorBase<self_t>(graph),
i_(graph.states().begin()),
end_(graph.states().end())
{
}
template <typename T>
StateIterator<T>::~StateIterator()
{}
template <typename T>
void
StateIterator<T>::op_next()
{
++i_;
}
template <typename T>
bool
StateIterator<T>::op_done() const
{
return i_ == end_;
}
template <typename T>
typename StateIterator<T>::hstate_t
StateIterator<T>::op_operator_star() const
{
return *i_;
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_HXX
// state_iterator_base.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_STATE_ITERATOR_BASE_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_BASE_HH
# include <vaucanson/automata/implementation/iterators/iterator_base.hh>
namespace vcsn
{
template <typename S>
struct StateIteratorBase;
/**
* Iterator traits.
*/
template <typename S>
struct iterator_traits_<StateIteratorBase<S> >
{
};
/**
* Base class for automaton iterators on transitions.
*/
template <typename S>
struct StateIteratorBase : IteratorBase<S>
{
/// Self type definition.
typedef StateIteratorBase<S> self_t;
typedef typename IteratorBase<S>::graph_t graph_t;
StateIteratorBase(graph_t graph);
~StateIteratorBase();
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/state_iterator_base.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_BASE_HH
// state_iterator_base.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_STATE_ITERATOR_BASE_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_BASE_HXX
# include <vaucanson/automata/implementation/iterators/state_iterator_base.hh>
namespace vcsn
{
template <typename S>
StateIteratorBase<S>::StateIteratorBase(graph_t graph)
: IteratorBase<S>(graph)
{}
template <typename S>
StateIteratorBase<S>::~StateIteratorBase()
{}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_STATE_ITERATOR_BASE_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