00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_MISC_SPARSE_INTERVAL_HH
00018 # define VCSN_MISC_SPARSE_INTERVAL_HH
00019 
00026 # include <iterator>
00027 # include <map>
00028 # include <string>
00029 
00030 namespace vcsn
00031 {
00032   namespace misc
00033   {
00034 
00037 
00038     template <class Integer, class ExcludedContainer>
00039     class SparseIterator
00040     {
00041       public:
00042         typedef Integer           integer_t;
00043         typedef ExcludedContainer excluded_container_t;
00044 
00045         SparseIterator (integer_t, const excluded_container_t&);
00046 
00047         SparseIterator& operator++ ();
00048         SparseIterator  operator++ (int);
00049         SparseIterator& operator-- ();
00050         SparseIterator  operator-- (int);
00051         integer_t       operator* ();
00052         bool            operator!= (const SparseIterator&);
00053         bool            operator== (const SparseIterator&);
00054         SparseIterator& operator= (const SparseIterator&);
00055 
00056       private:
00057         const excluded_container_t*     excluded_;
00058         integer_t                       integer_;
00059     };
00060 
00063   } 
00064 } 
00065 
00066 namespace std
00067 {
00068 
00069   template <class Integer, class ExcludedContainer>
00070   struct iterator_traits<vcsn::misc::SparseIterator
00071                          <Integer, ExcludedContainer> >
00072   {
00073       typedef input_iterator_tag iterator_category;
00074       typedef Integer              value_type;
00075       typedef int                  difference_type;
00076       typedef int*                 pointer;
00077       typedef int&                 reference;
00078   };
00079 
00080 } 
00081 
00082 namespace vcsn
00083 {
00084   namespace misc
00085   {
00086 
00097     template <class Integer, class ExcludedContainer>
00098     class SparseInterval
00099     {
00100       public:
00101         typedef Integer         integer_t;
00102         typedef ExcludedContainer       excluded_container_t;
00103         typedef SparseIterator<integer_t, excluded_container_t> iterator;
00104         typedef SparseIterator<integer_t, excluded_container_t> const_iterator;
00105 
00106         SparseInterval (integer_t, integer_t, const excluded_container_t&);
00107         SparseInterval (const SparseInterval&);
00108 
00109         iterator begin () const;
00110         iterator end () const;
00111         unsigned size () const;
00112         integer_t max () const;
00113         std::string to_string () const;
00114 
00115       private:
00116         const excluded_container_t&     excluded_;
00117         integer_t                       from_;
00118         integer_t                       to_;
00119     };
00120 
00121 
00124   } 
00125 } 
00126 
00127 
00128 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00129 #  include <vaucanson/misc/sparse_interval.hxx>
00130 # endif // VCSN_USE_INTERFACE_ONLY
00131 
00132 
00133 #endif // ! VCSN_MISC_SPARSE_INTERVAL_HH