BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Kernel_d/Cartesian_const_iterator_d.h
Go to the documentation of this file.
00001 // Copyright (c) 2000,2001,2008  Utrecht University (The Netherlands),
00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
00005 // and Tel-Aviv University (Israel).  All rights reserved.
00006 //
00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License as
00009 // published by the Free Software Foundation; version 2.1 of the License.
00010 // See the file LICENSE.LGPL distributed with CGAL.
00011 //
00012 // Licensees holding a valid commercial license may use this file in
00013 // accordance with the commercial license agreement provided with the software.
00014 //
00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 //
00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/trunk/Kernel_d/include/CGAL/Kernel_d/Tuple_d.h $
00019 // $Id: Tuple_d.h 42814 2008-04-09 16:07:00Z spion $
00020 //
00021 // Author(s)     : Michael Seel, Sylvain Pion
00022 
00023 #ifndef CGAL_CARTESIAN_CONST_ITERATOR_D_H
00024 #define CGAL_CARTESIAN_CONST_ITERATOR_D_H
00025 
00026 #include <CGAL/basic.h>
00027 #include <CGAL/Quotient.h>
00028 #include <iterator>
00029 
00030 CGAL_BEGIN_NAMESPACE
00031 
00032 // Takes an iterator over RT, and make one over FT, by dividing
00033 // by the last element.
00034 
00035 template < typename RT_iterator >
00036 class Cartesian_const_iterator_d
00037 {
00038   typedef typename std::iterator_traits<RT_iterator>::value_type RT;
00039   typedef Cartesian_const_iterator_d      self;
00040 
00041 public:
00042 
00043   typedef std::random_access_iterator_tag iterator_category;
00044   typedef CGAL::Quotient<RT>              value_type;
00045   typedef std::ptrdiff_t                  difference_type;
00046   typedef const value_type*               pointer;
00047   typedef const value_type&               reference;
00048 
00049   Cartesian_const_iterator_d() {}
00050   Cartesian_const_iterator_d(RT_iterator it, RT_iterator w)
00051     : _it(it), _w(w) {}
00052 
00053   self& operator++() { ++_it; return *this; }
00054   self  operator++(int) { self tmp = *this; ++_it; return tmp; }
00055   self& operator--() { --_it; return *this; }
00056   self  operator--(int) { self tmp = *this; --_it; return tmp; }
00057 
00058   self& operator+=(difference_type i) { _it+=i; return *this; }
00059   self& operator-=(difference_type i) { _it-=i; return *this; }
00060   self operator+(difference_type i) const
00061   { self tmp=*this; return tmp += i; }
00062   self operator-(difference_type i) const
00063   { self tmp=*this; return tmp -= i; }
00064 
00065   difference_type operator-(self x) const { return _it-x._it; }
00066 
00067   value_type operator*() const { return value_type(*_it,*_w); }
00068   value_type operator[](difference_type i) const { return *(*this + i); }
00069 
00070   bool operator==(const self& x) const { return _it==x._it; }
00071   bool operator!=(const self& x) const { return ! (*this==x); }
00072   bool operator<(const self& x) const { return (x - *this) > 0; }
00073 
00074 private:
00075   RT_iterator _it, _w;
00076 };
00077 
00078 template < typename RT_iterator > inline
00079 Cartesian_const_iterator_d<RT_iterator>
00080 make_cartesian_const_iterator_begin(RT_iterator begin, RT_iterator w)
00081 {
00082   return Cartesian_const_iterator_d<RT_iterator>(begin, w);
00083 }
00084 
00085 template < typename RT_iterator > inline
00086 Cartesian_const_iterator_d<RT_iterator>
00087 make_cartesian_const_iterator_end(RT_iterator w)
00088 {
00089   return Cartesian_const_iterator_d<RT_iterator>(w, w);
00090 }
00091 
00092 CGAL_END_NAMESPACE
00093 
00094 #endif // CGAL_CARTESIAN_CONST_ITERATOR_D_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines