Vaucanson  1.4.1
suffix.hxx
1 // suffix.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2011 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 VCSN_ALGORITHMS_SUFFIX_HXX
18 # define VCSN_ALGORITHMS_SUFFIX_HXX
19 
21 
22 # include <vaucanson/automata/concept/automata_base.hh>
24 # include <vaucanson/automata/implementation/transpose_view.hh>
25 # include <vaucanson/misc/usual_macros.hh>
27 
28 namespace vcsn {
29 
30  /*--------------.
31  | suffix_here |
32  `--------------*/
33 
34  template<typename A, typename AI>
35  void
36  suffix_here (Element<A, AI>& a)
37  {
38  precondition(is_realtime(a));
39  precondition(is_trim(a));
40 
41  typedef Element<A, AI> automaton_t;
42  AUTOMATON_TYPES (automaton_t);
43 
44  for_all_states (i, a)
45  a.set_initial (*i);
46  }
47 
48  /*---------.
49  | suffix |
50  `---------*/
51 
52  template<typename A, typename AI>
53  Element<A, AI>
54  suffix (const Element<A, AI>& a)
55  {
56  Element<A, AI> res (a);
57  suffix_here (res);
58  return (res);
59  }
60 
61 } // vcsn
62 
63 #endif // !VCSN_ALGORITHMS_SUFFIX_HXX