- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

# sparse_interval.hh

Go to the documentation of this file.

    00001 // sparse_interval.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Vaucanson Group.
    00006 //
    00007 // This program is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU General Public License
    00009 // as published by the Free Software Foundation; either version 2
    00010 // of the License, or (at your option) any later version.
    00011 //
    00012 // The complete GNU General Public Licence Notice can be found as the
    00013 // `COPYING' file in the root directory.
    00014 //
    00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    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   } // misc
    00064 } // vcsn
    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 } // std
    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
    00105         SparseInterval (integer_t, integer_t, const excluded_container_t&);
    00106         SparseInterval (const SparseInterval&);
    00107
    00108         iterator begin () const;
    00109         iterator end () const;
    00110         unsigned size () const;
    00111         integer_t max () const;
    00112         std::string to_string () const;
    00113
    00114       private:
    00115         const excluded_container_t&     excluded_;
    00116         integer_t                       from_;
    00117         integer_t                       to_;
    00118     };
    00119
    00120
    00123   } // misc
    00124 } // vcsn
    00125
    00126
    00127 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00128 #  include <vaucanson/misc/sparse_interval.hxx>
    00129 # endif // VCSN_USE_INTERFACE_ONLY
    00130
    00131
    00132 #endif // ! VCSN_MISC_SPARSE_INTERVAL_HH