00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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   } 
00103 } 
00104 
00105 #endif // ! VCSN_MISC_SELF_ITERATOR_HXX