support.hxx

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 
00023 namespace vcsn
00024 {
00025   namespace misc
00026   {
00027 
00028   /*------------------.
00029   | SupportIterator.  |
00030   `------------------*/
00031 
00032     template <class C>
00033     SupportIterator<C>::SupportIterator (map_iterator mp)
00034       : i (mp)
00035     {}
00036 
00037     template <class C>
00038     typename SupportIterator<C>::key_type
00039     SupportIterator<C>::operator* () const
00040     {
00041       return i->first;
00042     }
00043 
00044     template <class C>
00045     SupportIterator<C>& SupportIterator<C>::operator++ ()
00046     {
00047       ++i;
00048       return *this;
00049     }
00050 
00051     template <class C>
00052     SupportIterator<C> SupportIterator<C>::operator++ (int)
00053     {
00054       SupportIterator<C> tmp = *this;
00055       ++i;
00056       return tmp;
00057     }
00058 
00059     template <class C>
00060     bool
00061     SupportIterator<C>::operator!= (const SupportIterator& o) const
00062     {
00063       return o.i != i;
00064     }
00065 
00066     template <class C>
00067     bool
00068     SupportIterator<C>::operator== (const SupportIterator& o) const
00069     {
00070       return ! (*this != o);
00071     }
00072 
00073 
00074 
00075   /*----------.
00076   | Support.  |
00077   `----------*/
00078 
00079 
00081     template <class U, class T>
00082     Support<std::map<U, T> >::Support (const Support& s)
00083       : m_ (s.m_)
00084     {
00085     }
00086 
00087     template <class U, class T>
00088     Support<std::map<U, T> >::Support (const std::map<U, T>& m)
00089       : m_ (m)
00090     {
00091     }
00092 
00093     template <class U, class T>
00094     unsigned
00095     Support<std::map<U, T> >::size () const
00096     {
00097       return m_.size ();
00098     }
00099 
00100     template <class U, class T>
00101     typename Support<std::map<U, T> >::iterator
00102     Support<std::map<U, T> >::find (const U& k) const
00103     {
00104       return m_.find (k);
00105     }
00106 
00107     template <class U, class T>
00108     bool
00109     Support<std::map<U, T> >::empty () const
00110     {
00111       return m_.empty ();
00112     }
00113 
00114     template <class U, class T>
00115     typename Support<std::map<U, T> >::value_type
00116     Support<std::map<U, T> >::operator* () const
00117     {
00118       precondition (m_.size () == 1);
00119       return *m_.begin ();
00120     }
00121 
00122     template <class U, class T>
00123     typename Support<std::map<U, T> >::iterator
00124     Support<std::map<U, T> >::begin () const
00125     {
00126       return iterator (m_.begin ());
00127     }
00128 
00129     template <class U, class T>
00130     typename Support<std::map<U, T> >::iterator
00131     Support<std::map<U, T> >::end () const
00132     {
00133       return iterator (m_.end ());
00134     }
00135 
00136     template <class U, class T>
00137     U
00138     Support< std::map<U, T> >::max () const
00139     {
00140       return *max_element (begin (), end ());
00141     }
00142 
00143 
00144   } // misc
00145 } // vcsn
00146 
00147 #endif // ! VCSN_MISC_SUPPORT_HXX

Generated on Sun Jul 29 19:35:29 2007 for Vaucanson by  doxygen 1.5.2