Wiselib
wiselib.testing/util/pstl/reverse_iterator.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  ** This file is part of the generic algorithm library Wiselib.           **
00003  ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project.      **
00004  **                                                                       **
00005  ** The Wiselib is free software: you can redistribute it and/or modify   **
00006  ** it under the terms of the GNU Lesser General Public License as        **
00007  ** published by the Free Software Foundation, either version 3 of the    **
00008  ** License, or (at your option) any later version.                       **
00009  **                                                                       **
00010  ** The Wiselib is distributed in the hope that it will be useful,        **
00011  ** but WITHOUT ANY WARRANTY; without even the implied warranty of        **
00012  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         **
00013  ** GNU Lesser General Public License for more details.                   **
00014  **                                                                       **
00015  ** You should have received a copy of the GNU Lesser General Public      **
00016  ** License along with the Wiselib.                                       **
00017  ** If not, see <http://www.gnu.org/licenses/>.                           **
00018  ***************************************************************************/
00019 #ifndef __WISELIB_INTERNAL_INTERFACE_STL_REVERSE_ITERATOR_H_
00020 #define __WISELIB_INTERNAL_INTERFACE_STL_REVERSE_ITERATOR_H_
00021 
00022 namespace wiselib {
00023 
00027    template<typename Iterator_P>
00028    class reverse_iterator
00029    {
00030    public:
00031       // --------------------------------------------------------------------
00032       typedef reverse_iterator<Iterator_P> iterator_type;
00033 typedef      typename Iterator_P::reference reference;
00034       typedef typename Iterator_P::pointer pointer;
00035       // --------------------------------------------------------------------
00037       reverse_iterator( Iterator_P iterator ) :
00038       inner_iterator_( iterator )
00039       {
00040 
00041       }
00042       // --------------------------------------------------------------------
00043       reference operator*() const
00044       {
00045          return *inner_iterator_;
00046       }
00047       // --------------------------------------------------------------------
00048       pointer operator->() const
00049       {
00050          // TODO: test
00051          return &inner_iterator_;
00052       }
00053       // --------------------------------------------------------------------
00054       iterator_type& operator++()
00055       {
00056          --inner_iterator_;
00057          return *this;
00058       }
00059       // --------------------------------------------------------------------
00060       iterator_type operator++( int )
00061       {
00062          iterator_type tmp = *this;
00063          --inner_iterator_;
00064          return tmp;
00065       }
00066       // --------------------------------------------------------------------
00067       iterator_type& operator--()
00068       {
00069          ++inner_iterator_;
00070          return *this;
00071       }
00072       // --------------------------------------------------------------------
00073       iterator_type operator--( int )
00074       {
00075          iterator_type tmp = *this;
00076          ++inner_iterator_;
00077          return tmp;
00078       }
00079       // --------------------------------------------------------------------
00080       bool operator==( const reverse_iterator& x ) const
00081       {
00082          return inner_iterator_ == x.inner_iterator_;
00083       }
00084       // --------------------------------------------------------------------
00085       bool operator!=( const reverse_iterator& x ) const
00086       {
00087          return inner_iterator_ != x.inner_iterator_;
00088       }
00089       // --------------------------------------------------------------------
00090    private:
00091       Iterator_P inner_iterator_;
00092    };
00093 }
00094 
00095 #endif /* __WISELIB_INTERNAL_INTERFACE_STL_REVERSE_ITERATOR_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines