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 <string>
00029
00030 namespace vcsn
00031 {
00032 namespace misc
00033 {
00034
00037 template <class T>
00038 class Support;
00039
00042 template <class C>
00043 class SupportIterator
00044 {
00045 public:
00046 typedef typename C::key_type key_type;
00047 typedef typename C::const_iterator map_iterator;
00048 typedef SupportIterator<C> self_t;
00049
00050 typedef typename map_iterator::iterator_category iterator_category;
00051 typedef typename map_iterator::difference_type difference_type;
00052 typedef key_type value_type;
00053 typedef key_type* pointer;
00054 typedef key_type& reference;
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 SupportIterator () {}
00081 SupportIterator (map_iterator);
00082
00083 key_type operator* () const;
00084 self_t& operator++ ();
00085 self_t operator++ (int);
00086 bool operator!= (const SupportIterator&) const;
00087 bool operator== (const SupportIterator&) const;
00088
00089 private:
00090 map_iterator i;
00091 };
00092
00094 template <class U, class T>
00095 class Support<std::map<U, T> >
00096 {
00097 public:
00098 typedef SupportIterator<std::map<U, T> > iterator;
00099 typedef SupportIterator<std::map<U, T> > const_iterator;
00101 typedef typename std::map<U, T>::value_type value_type;
00102
00103 Support (const std::map<U, T>&);
00104 Support (const Support&);
00105
00108 value_type operator* () const;
00109
00110 iterator begin () const;
00111 iterator end () const;
00112 unsigned size () const;
00113
00114
00115 iterator find (const U& k) const;
00116
00118 bool empty () const;
00119
00120 U max () const;
00121 private:
00122 const std::map<U, T>& m_;
00123 };
00124
00127 }
00128 }
00129
00130 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00131 # include <vaucanson/misc/support.hxx>
00132 # endif // VCSN_USE_INTERFACE_ONLY
00133
00134
00135 #endif // ! VCSN_MISC_SUPPORT_HH