Vaucanson  1.4.1
listg_sparse_interval.hh
Go to the documentation of this file.
1 // listg_sparse_interval.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, 2007, 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 VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH
18 # define VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH
19 
26 # include <vaucanson/automata/concept/handlers.hh>
28 
29 namespace vcsn
30 {
31  namespace misc
32  {
33 
36 
37  template <class T, class ExcludedContainer>
38  class SparseIterator<vcsn::handler<T, unsigned>, ExcludedContainer>
39  {
40  public:
41  typedef vcsn::handler<T, unsigned> handler_t;
42  typedef handler_t integer_t;
43  typedef ExcludedContainer excluded_container_t;
44  typedef typename excluded_container_t::const_iterator iterator_t;
45 
46  SparseIterator (integer_t, const excluded_container_t&);
47 
48  SparseIterator& operator++ ();
49  SparseIterator operator++ (int);
50  SparseIterator& operator-- ();
51  SparseIterator operator-- (int);
52  integer_t operator* ();
53  bool operator!= (const SparseIterator&) const;
54  bool operator== (const SparseIterator&) const;
55  SparseIterator& operator= (const SparseIterator&);
56 
57  private:
58  const excluded_container_t* excluded_;
59  unsigned integer_;
60  };
61 
64  } // misc
65 } // vcsn
66 
67 namespace std
68 {
69 
70  template <class T, class ExcludedContainer>
71  struct iterator_traits<vcsn::misc::SparseIterator
72  <vcsn::handler<T, unsigned>, ExcludedContainer> >
73  {
74  typedef input_iterator_tag iterator_category;
75  typedef vcsn::handler<T, unsigned> value_type;
76  typedef int difference_type;
77  typedef int* pointer;
78  typedef int& reference;
79  };
80 
81 } // std
82 
83 namespace vcsn
84 {
85  namespace misc
86  {
87 
104  template <class T, class ExcludedContainer>
105  class SparseInterval<vcsn::handler<T, unsigned>, ExcludedContainer>
106  {
107  public:
108  typedef vcsn::handler<T, unsigned> handler_t;
109  typedef handler_t integer_t;
110  typedef ExcludedContainer excluded_container_t;
113 
114  SparseInterval (integer_t, integer_t, const excluded_container_t&);
116 
117  iterator begin () const;
118  iterator end () const;
119  //Return the number of elements which are _NOT_ excluded.
120  unsigned size () const;
121  std::string to_string () const;
122  //Return the handler_t with the highest ID.
123  handler_t back() const;
124 
125  private:
126  const excluded_container_t& excluded_;
127  unsigned from_;
128  unsigned to_;
129  };
130 
131 
134  } // misc
135 } // vcsn
136 
137 
138 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
139 # include <vaucanson/automata/implementation/listg/listg_sparse_interval.hxx>
140 # endif // VCSN_USE_INTERFACE_ONLY
141 
142 
143 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH