Vaucanson  1.4.1
listg/iterator.hxx
1 // iterator.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX
18 # define VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX
19 
20 # include <vaucanson/automata/implementation/listg/iterator.hh>
21 
22 namespace vcsn
23 {
24  namespace listg
25  {
26 
27  // Syntactic sugar
28 # define LISTG_ITERATOR_TPARAM template <typename Graph, typename Direction>
29 # define LISTG_ITERATOR DeltaConstIterator<Graph, Direction>
30 
31  LISTG_ITERATOR_TPARAM
32  LISTG_ITERATOR::DeltaConstIterator(const graph_type& g, typename graph_type::hstate_t s)
33  : graph_(g), s_(s)
34  {
35  initialize(direction());
36  }
37 
38  LISTG_ITERATOR_TPARAM
39  LISTG_ITERATOR::~DeltaConstIterator()
40  { }
41 
42  LISTG_ITERATOR_TPARAM
43  void
44  LISTG_ITERATOR::next()
45  {
46  ++i_;
47  }
48 
49  LISTG_ITERATOR_TPARAM
50  bool
51  LISTG_ITERATOR::done() const
52  {
53  return i_ == end_;
54  }
55 
56  LISTG_ITERATOR_TPARAM
57  void
58  LISTG_ITERATOR::initialize(const backward_iterator&)
59  {
60  i_ = graph_.states_[s_].input_edges.begin();
61  end_ = graph_.states_[s_].input_edges.end();
62  }
63 
64  LISTG_ITERATOR_TPARAM
65  void
66  LISTG_ITERATOR::initialize(const forward_iterator&)
67  {
68  i_ = graph_.states_[s_].output_edges.begin();
69  end_ = graph_.states_[s_].output_edges.end();
70  }
71 
72  LISTG_ITERATOR_TPARAM
73  typename LISTG_ITERATOR::graph_type::htransition_t
75  {
76  return *i_;
77  }
78 
79 # undef LISTG_ITERATOR_TPARAM
80 # undef LISTG_ITERATOR
81 
82  } // End of namespace listg
83 
84 } // End of namespace vcsn
85 
86 
87 #endif // ! VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX