Vaucanson 1.4
listg_sparse_interval.hh
Go to the documentation of this file.
00001 // listg_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, 2008 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_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH
00018 # define VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH
00019 
00026 # include <vaucanson/automata/concept/handlers.hh>
00027 # include <vaucanson/misc/sparse_interval.hh>
00028 
00029 namespace vcsn
00030 {
00031   namespace misc
00032   {
00033 
00036 
00037     template <class T, class ExcludedContainer>
00038     class SparseIterator<vcsn::handler<T, unsigned>, ExcludedContainer>
00039     {
00040       public:
00041         typedef vcsn::handler<T, unsigned>      handler_t;
00042         typedef handler_t               integer_t;
00043         typedef ExcludedContainer       excluded_container_t;
00044         typedef typename excluded_container_t::const_iterator  iterator_t;
00045 
00046         SparseIterator (integer_t, const excluded_container_t&);
00047 
00048         SparseIterator& operator++ ();
00049         SparseIterator  operator++ (int);
00050         SparseIterator& operator-- ();
00051         SparseIterator  operator-- (int);
00052         integer_t       operator* ();
00053         bool            operator!= (const SparseIterator&) const;
00054         bool            operator== (const SparseIterator&) const;
00055         SparseIterator& operator= (const SparseIterator&);
00056 
00057       private:
00058         const excluded_container_t* excluded_;
00059         unsigned                    integer_;
00060     };
00061 
00064   } // misc
00065 } // vcsn
00066 
00067 namespace std
00068 {
00069 
00070   template <class T, class ExcludedContainer>
00071   struct iterator_traits<vcsn::misc::SparseIterator
00072                          <vcsn::handler<T, unsigned>, ExcludedContainer> >
00073   {
00074       typedef input_iterator_tag                iterator_category;
00075       typedef vcsn::handler<T, unsigned>                value_type;
00076       typedef int                               difference_type;
00077       typedef int*                              pointer;
00078       typedef int&                              reference;
00079   };
00080 
00081 } // std
00082 
00083 namespace vcsn
00084 {
00085   namespace misc
00086   {
00087 
00104     template <class T, class ExcludedContainer>
00105     class SparseInterval<vcsn::handler<T, unsigned>, ExcludedContainer>
00106     {
00107       public:
00108         typedef vcsn::handler<T, unsigned>      handler_t;
00109         typedef handler_t               integer_t;
00110         typedef ExcludedContainer       excluded_container_t;
00111         typedef SparseIterator<integer_t, excluded_container_t> iterator;
00112         typedef SparseIterator<integer_t, excluded_container_t> const_iterator;
00113 
00114         SparseInterval (integer_t, integer_t, const excluded_container_t&);
00115         SparseInterval (const SparseInterval&);
00116 
00117         iterator begin () const;
00118         iterator end () const;
00119         //Return the number of elements which are _NOT_ excluded.
00120         unsigned size () const;
00121         std::string to_string () const;
00122         //Return the handler_t with the highest ID.
00123         handler_t back() const;
00124 
00125       private:
00126         const excluded_container_t&     excluded_;
00127         unsigned                        from_;
00128         unsigned                        to_;
00129     };
00130 
00131 
00134   } // misc
00135 } // vcsn
00136 
00137 
00138 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00139 #  include <vaucanson/automata/implementation/listg/listg_sparse_interval.hxx>
00140 # endif // VCSN_USE_INTERFACE_ONLY
00141 
00142 
00143 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HH