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

Add entry iterators.

* include/Makefile.am: Add new files.
* include/vaucanson/automata/implementation/iterators/delta_entry_iterator.hh,
* include/vaucanson/automata/implementation/iterators/delta_entry_iterator.hxx,
* include/vaucanson/automata/implementation/iterators/entry_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/entry_iterator_base.hxx,
* include/vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hh,
* include/vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hxx:
New. Interface & implementation.
parent fe50c541
2009-10-08 d-halluin <d-halluin@lrde.epita.fr>
Add entry iterators.
* include/Makefile.am: Add new files.
* include/vaucanson/automata/implementation/iterators/delta_entry_iterator.hh,
* include/vaucanson/automata/implementation/iterators/delta_entry_iterator.hxx,
* include/vaucanson/automata/implementation/iterators/entry_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/entry_iterator_base.hxx,
* include/vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hh,
* include/vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hxx:
New. Interface & implementation.
2009-09-30 d-halluin <d-halluin@lrde.epita.fr>
 
Update CBS.
......
......@@ -530,6 +530,12 @@ 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/iterators/entry_iterator_base.hh \
vaucanson/automata/implementation/iterators/entry_iterator_base.hxx \
vaucanson/automata/implementation/iterators/delta_entry_iterator.hh \
vaucanson/automata/implementation/iterators/delta_entry_iterator.hxx \
vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hh \
vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hxx \
vaucanson/automata/implementation/transpose_view.hh \
vaucanson/automata/implementation/transpose_view.hxx
......
// delta_entry_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_DELTA_ENTRY_ITERATOR_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_ENTRY_ITERATOR_HH
# include <vaucanson/automata/implementation/iterators/entry_iterator_base.hh>
# include <set>
namespace vcsn
{
template <typename T>
struct DeltaEntryIterator;
/**
* Iterator traits.
*/
template <typename T>
struct iterator_traits_<DeltaEntryIterator<T> >
{
typedef T graph_t;
typedef typename graph_t::series_set_elt_value_t value_type;
};
/**
* Class for iterators on the successors of a given state.
*
* Note on implementation:
* Iterate on the successors and compute a list of states.
* FIXME: no implementation for the * operator (since the iterator
* does not have access to the automaton).
*
* Changes in transition between this state and its successors
* should invalidate the iterator.
*/
template <typename T>
struct DeltaEntryIterator
: EntryIteratorBase<DeltaEntryIterator<T> >
{
/// Self type definition.
typedef DeltaEntryIterator<T> self_t;
typedef typename EntryIteratorBase<self_t>::graph_t graph_t;
// Typedefs
typedef typename graph_t::series_set_elt_value_t entry_value_t;
typedef typename graph_t::hstate_t hstate_t;
DeltaEntryIterator(const graph_t& graph,
typename graph_t::hstate_t state);
~DeltaEntryIterator();
void op_next();
bool op_done() const;
entry_value_t op_operator_star() const;
hstate_t op_src() const;
hstate_t op_dst() const;
private:
hstate_t state_;
typename std::set<hstate_t> successors_;
typename std::set<hstate_t>::iterator i_;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/delta_entry_iterator.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_ENTRY_ITERATOR_HH
// delta_entry_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_DELTA_ENTRY_ITERATOR_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_ENTRY_ITERATOR_HXX
# include <vaucanson/automata/implementation/iterators/delta_entry_iterator.hh>
namespace vcsn
{
template <typename T>
DeltaEntryIterator<T>::DeltaEntryIterator(const graph_t& graph,
hstate_t state)
: EntryIteratorBase<self_t>(graph),
state_(state)
{
typename graph_t::delta_iterator i(graph, state);
while (!i.done())
{
successors_.insert(graph.dst_of(*i));
i.next();
}
i_ = successors_.begin();
}
template <typename T>
DeltaEntryIterator<T>::~DeltaEntryIterator()
{}
template <typename T>
typename DeltaEntryIterator<T>::hstate_t
DeltaEntryIterator<T>::op_src() const
{
return state_;
}
template <typename T>
typename DeltaEntryIterator<T>::hstate_t
DeltaEntryIterator<T>::op_dst() const
{
return *i_;
}
template <typename T>
void
DeltaEntryIterator<T>::op_next()
{
i_++;
}
template <typename T>
bool
DeltaEntryIterator<T>::op_done() const
{
return i_ == successors_.end();
}
template <typename T>
typename DeltaEntryIterator<T>::entry_value_t
DeltaEntryIterator<T>::op_operator_star() const
{
// FIXME: Series cannot be built without access to the
// automaton_t. Here we only have the graph.
static_error(no_implementation_for_operator_star);
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_ENTRY_ITERATOR_HXX
// entry_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_ENTRY_ITERATOR_BASE_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_ENTRY_ITERATOR_BASE_HH
# include <vaucanson/automata/implementation/iterators/iterator_base.hh>
namespace vcsn
{
template <typename S>
struct EntryIteratorBase;
/**
* Iterator traits.
*/
template <typename S>
struct iterator_traits_<EntryIteratorBase<S> >
{
};
/**
* Base class for automaton iterators on entries.
*/
template <typename S>
struct EntryIteratorBase : IteratorBase<S>
{
/// Self type definition.
typedef EntryIteratorBase<S> self_t;
typedef typename IteratorBase<S>::graph_t graph_t;
EntryIteratorBase(graph_t graph);
~EntryIteratorBase();
typename graph_t::hstate_t src() const;
typename graph_t::hstate_t dst() const;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/entry_iterator_base.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_ENTRY_ITERATOR_BASE_HH
// entry_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_ENTRY_ITERATOR_BASE_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_ENTRY_ITERATOR_BASE_HXX
# include <vaucanson/automata/implementation/iterators/entry_iterator_base.hh>
namespace vcsn
{
template <typename S>
EntryIteratorBase<S>::EntryIteratorBase(graph_t graph)
: IteratorBase<S>(graph)
{}
template <typename S>
EntryIteratorBase<S>::~EntryIteratorBase()
{}
template <typename S>
typename EntryIteratorBase<S>::graph_t::hstate_t
EntryIteratorBase<S>::src() const
{
return static_cast<const S*>(this)->op_src();
}
template <typename S>
typename EntryIteratorBase<S>::graph_t::hstate_t
EntryIteratorBase<S>::dst() const
{
return static_cast<const S*>(this)->op_dst();
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_ENTRY_ITERATOR_BASE_HXX
// rdelta_entry_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_RDELTA_ENTRY_ITERATOR_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_RDELTA_ENTRY_ITERATOR_HH
# include <vaucanson/automata/implementation/iterators/entry_iterator_base.hh>
# include <set>
namespace vcsn
{
template <typename T>
struct RDeltaEntryIterator;
/**
* Iterator traits.
*/
template <typename T>
struct iterator_traits_<RDeltaEntryIterator<T> >
{
typedef T graph_t;
typedef typename graph_t::series_set_elt_value_t value_type;
};
/**
* Class for iterators on the predecessors of a given state.
*
* Note on implementation:
* Iterate on the predecessors and compute a list of states.
* FIXME: no implementation for the * operator (since the iterator
* does not have access to the automaton).
*
* Changes in transition between this state and its predecessors
* should invalidate the iterator.
*/
template <typename T>
struct RDeltaEntryIterator
: EntryIteratorBase<RDeltaEntryIterator<T> >
{
/// Self type definition.
typedef RDeltaEntryIterator<T> self_t;
typedef typename EntryIteratorBase<self_t>::graph_t graph_t;
// Typedefs
typedef typename graph_t::series_set_elt_value_t entry_value_t;
typedef typename graph_t::hstate_t hstate_t;
RDeltaEntryIterator(const graph_t& graph,
typename graph_t::hstate_t state);
~RDeltaEntryIterator();
void op_next();
bool op_done() const;
entry_value_t op_operator_star() const;
hstate_t op_src() const;
hstate_t op_dst() const;
private:
hstate_t state_;
typename std::set<hstate_t> predecessors_;
typename std::set<hstate_t>::iterator i_;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_RDELTA_ENTRY_ITERATOR_HH
// rdelta_entry_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_RDELTA_ENTRY_ITERATOR_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_RDELTA_ENTRY_ITERATOR_HXX
# include <vaucanson/automata/implementation/iterators/rdelta_entry_iterator.hh>
namespace vcsn
{
template <typename T>
RDeltaEntryIterator<T>::RDeltaEntryIterator(const graph_t& graph,
hstate_t state)
: EntryIteratorBase<self_t>(graph),
state_(state)
{
typename graph_t::rdelta_iterator i(graph, state);
while (!i.done())
{
predecessors_.insert(graph.dst_of(*i));
i.next();
}
i_ = predecessors_.begin();
}
template <typename T>
RDeltaEntryIterator<T>::~RDeltaEntryIterator()
{}
template <typename T>
typename RDeltaEntryIterator<T>::hstate_t
RDeltaEntryIterator<T>::op_src() const
{
return state_;
}
template <typename T>
typename RDeltaEntryIterator<T>::hstate_t
RDeltaEntryIterator<T>::op_dst() const
{
return *i_;
}
template <typename T>
void
RDeltaEntryIterator<T>::op_next()
{
i_++;
}
template <typename T>
bool
RDeltaEntryIterator<T>::op_done() const
{
return i_ == predecessors_.end();
}
template <typename T>
typename RDeltaEntryIterator<T>::entry_value_t
RDeltaEntryIterator<T>::op_operator_star() const
{
// FIXME: Series cannot be built without access to the
// automaton_t. Here we only have the graph.
static_error(no_implementation_for_operator_star);
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_RDELTA_ENTRY_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