self_iterator.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_SELF_ITERATOR_HXX
00018 # define VCSN_MISC_SELF_ITERATOR_HXX
00019 
00020 # include <vaucanson/misc/self_iterator.hh>
00021 
00022 namespace vcsn
00023 {
00024   namespace misc
00025   {
00026 
00027     template <template <class> class C, class T>
00028     inline
00029     SelfIterator<C, T>::SelfIterator (const C<T>& c)
00030       : c_ (&c),
00031         pos_ (c.begin ())
00032     {}
00033 
00034     template <template <class> class C, class T>
00035     inline
00036     SelfIterator<C, T>::SelfIterator ()
00037       : c_ (0),
00038         pos_ ()
00039     {}
00040 
00041     template <template <class> class C, class T>
00042     inline
00043     SelfIterator<C, T>::SelfIterator (const SelfIterator& s)
00044       : c_ (s.c_),
00045         pos_ (s.pos_)
00046     {}
00047 
00048     template <template <class> class C, class T>
00049     inline
00050     const T&
00051     SelfIterator<C, T>::operator* () const
00052     {
00053       return *pos_;
00054     }
00055 
00056     template <template <class> class C, class T>
00057     inline
00058     const SelfIterator<C, T>&
00059     SelfIterator<C, T>::operator++ ()
00060     {
00061       pos_++;
00062       return *this;
00063     }
00064 
00065     template <template <class> class C, class T>
00066     inline
00067     SelfIterator<C, T>
00068     SelfIterator<C, T>::operator++ (int)
00069     {
00070       SelfIterator<C, T> res (*this);
00071       ++pos_;
00072       return res;
00073     }
00074 
00075     template <template <class> class C, class T>
00076     inline
00077     bool
00078     SelfIterator<C, T>::operator!= (const SelfIterator<C, T>& o) const
00079     {
00080       if (c_ == 0)
00081         if (o.c_ == 0)
00082           return false;
00083         else
00084           return o.pos_ != o.c_->end ();
00085       else if (o.c_ == 0)
00086         return pos_ != c_->end ();
00087       return o.c_ != c_ || o.pos_ != pos_;
00088     }
00089 
00090     template <template <class> class C, class T>
00091     inline
00092     bool
00093     SelfIterator<C, T>::operator== (const SelfIterator<C, T>& o) const
00094     {
00095       if (c_ == 0)
00096         return o.c_ == 0 || o.pos_ == o.c_->end ();
00097       else if (o.c_ == 0)
00098         return pos_ == c_->end ();
00099       return o.c_ == c_ && o.pos_ == pos_;
00100     }
00101 
00102   } // misc
00103 } // vcsn
00104 
00105 #endif // ! VCSN_MISC_SELF_ITERATOR_HXX

Generated on Wed Jun 13 17:00:29 2007 for Vaucanson by  doxygen 1.5.1