00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_MISC_SUPPORT_HH
00018 # define VCSN_MISC_SUPPORT_HH
00019 
00026 # include <iterator>
00027 # include <map>
00028 # include <set>
00029 # include <string>
00030 # include <vector>
00031 # include <vaucanson/automata/concept/handlers.hh>
00032 
00033 
00034 namespace vcsn
00035 {
00036   namespace misc
00037   {
00038 
00041     template <typename T>
00042     class Support;
00043 
00046     template <class C>
00047     class SupportIterator
00048     {
00049       public:
00050         typedef typename C::key_type            key_type;
00051         typedef typename C::const_iterator      map_iterator;
00052         typedef SupportIterator<C>              self_t;
00053 
00054         typedef typename map_iterator::iterator_category iterator_category;
00055         typedef typename map_iterator::difference_type   difference_type;
00056         typedef key_type                                 value_type;
00057         typedef key_type*                                pointer;
00058         typedef key_type&                                reference;
00059 
00060         
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084         SupportIterator () {}
00085         SupportIterator (map_iterator);
00086 
00087         key_type operator* () const;
00088         self_t&  operator++ ();
00089         self_t   operator++ (int);
00090         bool     operator!= (const SupportIterator&) const;
00091         bool     operator== (const SupportIterator&) const;
00092 
00093       private:
00094         map_iterator    i;
00095     };
00096 
00097     template <class U>
00098     class SupportIterator<std::set<U> >
00099     {
00100       public:
00101         typedef std::set<U>                             container_t;
00102         typedef U                                       value_t;
00103         typedef typename container_t::const_iterator    iterator;
00104         typedef SupportIterator<std::set<U> >           self_t;
00105 
00106         typedef typename iterator::iterator_category    iterator_category;
00107         typedef typename iterator::difference_type      difference_type;
00108         typedef value_t                                 value_type;
00109         typedef value_t*                                pointer;
00110         typedef value_t&                                reference;
00111 
00112         
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136         SupportIterator () {}
00137         SupportIterator (iterator);
00138 
00139         value_t operator* () const;
00140         self_t&  operator++ ();
00141         self_t   operator++ (int);
00142         bool     operator!= (const SupportIterator&) const;
00143         bool     operator== (const SupportIterator&) const;
00144 
00145       private:
00146         iterator        i;
00147     };
00148 
00150     template <class U, class T>
00151     class Support<std::map<U, T> >
00152     {
00153       public:
00154         typedef SupportIterator<std::map<U, T> > iterator;
00155         typedef SupportIterator<std::map<U, T> > const_iterator;
00157         typedef typename std::map<U, T>::value_type value_type;
00158 
00159         Support (const std::map<U, T>&);
00160         Support (const Support&);
00161 
00162         iterator begin () const;
00163         iterator end () const;
00164         unsigned size () const;
00165 
00166         
00167         iterator find (const U& k) const;
00168 
00170         bool empty () const;
00171 
00172         U back () const;
00173       private:
00174         const std::map<U, T>&   m_;
00175     };
00176 
00178     template <class U>
00179     class Support<std::set<U> >
00180     {
00181       public:
00182         typedef SupportIterator<std::set<U> > iterator;
00183         typedef SupportIterator<std::set<U> > const_iterator;
00185         typedef typename std::set<U>::value_type value_type;
00186 
00187         Support (const std::set<U>&);
00188         Support (const Support&);
00189 
00190         iterator begin () const;
00191         iterator end () const;
00192         unsigned size () const;
00193 
00194         
00195         iterator find (const U& k) const;
00196 
00198         bool empty () const;
00199 
00200         U back () const;
00201       private:
00202         const std::set<U>&      m_;
00203     };
00206   } 
00207 } 
00208 
00209 
00210 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00211 #  include <vaucanson/misc/support.hxx>
00212 # endif // VCSN_USE_INTERFACE_ONLY
00213 
00214 
00215 #endif // ! VCSN_MISC_SUPPORT_HH