Vaucanson  1.4.1
sparse_interval.hh
Go to the documentation of this file.
1 // 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_MISC_SPARSE_INTERVAL_HH
18 # define VCSN_MISC_SPARSE_INTERVAL_HH
19 
26 # include <iterator>
27 # include <map>
28 # include <string>
29 
30 namespace vcsn
31 {
32  namespace misc
33  {
34 
37 
38  template <class Integer, class ExcludedContainer>
40  {
41  public:
42  typedef Integer integer_t;
43  typedef ExcludedContainer excluded_container_t;
44 
45  SparseIterator (integer_t, const excluded_container_t&);
46 
47  SparseIterator& operator++ ();
48  SparseIterator operator++ (int);
49  SparseIterator& operator-- ();
50  SparseIterator operator-- (int);
51  integer_t operator* ();
52  bool operator!= (const SparseIterator&) const;
53  bool operator== (const SparseIterator&) const;
54  SparseIterator& operator= (const SparseIterator&);
55 
56  private:
57  const excluded_container_t* excluded_;
58  integer_t integer_;
59  };
60 
63  } // misc
64 } // vcsn
65 
66 namespace std
67 {
68 
69  template <class Integer, class ExcludedContainer>
70  struct iterator_traits<vcsn::misc::SparseIterator
71  <Integer, ExcludedContainer> >
72  {
73  typedef input_iterator_tag iterator_category;
74  typedef Integer value_type;
75  typedef int difference_type;
76  typedef int* pointer;
77  typedef int& reference;
78  };
79 
80 } // std
81 
82 namespace vcsn
83 {
84  namespace misc
85  {
86 
97  template <class Integer, class ExcludedContainer>
99  {
100  public:
101  typedef Integer integer_t;
102  typedef ExcludedContainer excluded_container_t;
105 
106  SparseInterval (integer_t, integer_t, const excluded_container_t&);
108 
109  iterator begin () const;
110  iterator end () const;
111  unsigned size () const;
112  integer_t max () const;
113  std::string to_string () const;
114 
115  private:
116  const excluded_container_t& excluded_;
117  integer_t from_;
118  integer_t to_;
119  };
120 
121 
124  } // misc
125 } // vcsn
126 
127 
128 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
129 # include <vaucanson/misc/sparse_interval.hxx>
130 # endif // VCSN_USE_INTERFACE_ONLY
131 
132 
133 #endif // ! VCSN_MISC_SPARSE_INTERVAL_HH