Vaucanson  1.4.1
automaton_tools.hh
1 // automaton_tools.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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_TOOLS_AUTOMATON_TOOLS_HH
18 # define VCSN_TOOLS_AUTOMATON_TOOLS_HH
19 
20 # include <algorithm>
21 # include <deque>
22 # include <vaucanson/automata/concept/automata.hh>
23 # include <vaucanson/misc/random.hh>
24 
25 namespace vcsn
26 {
27  namespace tools
28  {
29  template <class Auto>
30  std::deque<typename Auto::hstate_t>
31  choose_n_states(const Auto& a, unsigned n)
32  {
33  typedef typename Auto::hstate_t hstate_t;
34 
35  std::deque<typename Auto::hstate_t> s;
36  std::insert_iterator<std::deque<hstate_t> > i(s, s.begin());
37  misc::random::sample_n(hstate_t(),
38  a.states().begin(),
39  a.states().end(),
40  i,
41  n);
42  return s;
43  }
44  } // tools
45 } // vcsn
46 
47 #endif // ! VCSN_TOOLS_AUTOMATON_TOOLS_HH