Vaucanson 1.4
|
00001 // support.hxx: 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_SUPPORT_HXX 00018 # define VCSN_MISC_SUPPORT_HXX 00019 00020 # include <vaucanson/misc/support.hh> 00021 # include <vaucanson/misc/contract.hh> 00022 # include <vaucanson/automata/concept/handlers.hh> 00023 00024 namespace vcsn 00025 { 00026 namespace misc 00027 { 00028 00029 /*----------. 00030 | Support. | 00031 `----------*/ 00032 00034 template <class U, class T> 00035 Support<std::map<U, T> >::Support (const Support& s) 00036 : m_ (s.m_) 00037 { 00038 } 00039 00040 template <class U, class T> 00041 Support<std::map<U, T> >::Support (const std::map<U, T>& m) 00042 : m_ (m) 00043 { 00044 } 00045 00046 template <class U, class T> 00047 unsigned 00048 Support<std::map<U, T> >::size () const 00049 { 00050 return m_.size (); 00051 } 00052 00053 template <class U, class T> 00054 typename Support<std::map<U, T> >::iterator 00055 Support<std::map<U, T> >::find (const U& k) const 00056 { 00057 return m_.find (k); 00058 } 00059 00060 template <class U, class T> 00061 bool 00062 Support<std::map<U, T> >::empty () const 00063 { 00064 return m_.empty (); 00065 } 00066 00067 template <class U, class T> 00068 typename Support<std::map<U, T> >::iterator 00069 Support<std::map<U, T> >::begin () const 00070 { 00071 return iterator (m_.begin ()); 00072 } 00073 00074 template <class U, class T> 00075 typename Support<std::map<U, T> >::iterator 00076 Support<std::map<U, T> >::end () const 00077 { 00078 return iterator (m_.end ()); 00079 } 00080 00081 template <class U, class T> 00082 U 00083 Support< std::map<U, T> >::back () const 00084 { 00085 return *max_element (begin (), end ()); 00086 } 00087 00089 template <class U> 00090 Support<std::set<U> >::Support (const Support& s) 00091 : m_ (s.m_) 00092 { 00093 } 00094 00095 template <class U> 00096 Support<std::set<U> >::Support (const std::set<U>& m) 00097 : m_ (m) 00098 { 00099 } 00100 00101 template <class U> 00102 unsigned 00103 Support<std::set<U> >::size () const 00104 { 00105 return m_.size (); 00106 } 00107 00108 template <class U> 00109 typename Support<std::set<U> >::iterator 00110 Support<std::set<U> >::find (const U& k) const 00111 { 00112 return m_.find (k); 00113 } 00114 00115 template <class U> 00116 bool 00117 Support<std::set<U> >::empty () const 00118 { 00119 return m_.empty (); 00120 } 00121 00122 template <class U> 00123 typename Support<std::set<U> >::iterator 00124 Support<std::set<U> >::begin () const 00125 { 00126 return iterator (m_.begin ()); 00127 } 00128 00129 template <class U> 00130 typename Support<std::set<U> >::iterator 00131 Support<std::set<U> >::end () const 00132 { 00133 return iterator (m_.end ()); 00134 } 00135 00136 template <class U> 00137 U 00138 Support< std::set<U> >::back () const 00139 { 00140 return *max_element (begin (), end ()); 00141 } 00142 00143 /*------------------. 00144 | SupportIterator. | 00145 `------------------*/ 00146 00147 template <class C> 00148 SupportIterator<C>::SupportIterator (map_iterator mp) 00149 : i (mp) 00150 {} 00151 00152 template <class C> 00153 typename SupportIterator<C>::key_type 00154 SupportIterator<C>::operator* () const 00155 { 00156 return i->first; 00157 } 00158 00159 template <class C> 00160 SupportIterator<C>& SupportIterator<C>::operator++ () 00161 { 00162 ++i; 00163 return *this; 00164 } 00165 00166 template <class C> 00167 SupportIterator<C> SupportIterator<C>::operator++ (int) 00168 { 00169 SupportIterator<C> tmp = *this; 00170 ++i; 00171 return tmp; 00172 } 00173 00174 template <class C> 00175 bool 00176 SupportIterator<C>::operator!= (const SupportIterator& o) const 00177 { 00178 return o.i != i; 00179 } 00180 00181 template <class C> 00182 bool 00183 SupportIterator<C>::operator== (const SupportIterator& o) const 00184 { 00185 return ! (*this != o); 00186 } 00187 00188 /*------------------. 00189 | SupportIterator. | 00190 `------------------*/ 00191 00192 template <class U> 00193 SupportIterator<std::set<U> >::SupportIterator (iterator mp) 00194 : i (mp) 00195 {} 00196 00197 template <class U> 00198 typename SupportIterator<std::set<U> >::value_t 00199 SupportIterator<std::set<U> >::operator* () const 00200 { 00201 return *i; 00202 } 00203 00204 template <class U> 00205 SupportIterator<std::set<U> >& 00206 SupportIterator<std::set<U> >::operator++ () 00207 { 00208 ++i; 00209 return *this; 00210 } 00211 00212 template <class U> 00213 SupportIterator<std::set<U> > 00214 SupportIterator<std::set<U> >::operator++ (int) 00215 { 00216 SupportIterator<std::set<U> > tmp = *this; 00217 ++i; 00218 return tmp; 00219 } 00220 00221 template <class U> 00222 bool 00223 SupportIterator<std::set<U> >::operator!= (const SupportIterator& o) const 00224 { 00225 return o.i != i; 00226 } 00227 00228 template <class U> 00229 bool 00230 SupportIterator<std::set<U> >::operator== (const SupportIterator& o) const 00231 { 00232 return ! (*this != o); 00233 } 00234 00235 } // misc 00236 } // vcsn 00237 00238 #endif // ! VCSN_MISC_SUPPORT_HXX