BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Circulator_project.h
Go to the documentation of this file.
00001 // Copyright (c) 2003  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/branches/CGAL-3.5-branch/STL_Extension/include/CGAL/Circulator_project.h $
00019 // $Id: Circulator_project.h 46206 2008-10-11 20:21:08Z spion $
00020 // 
00021 //
00022 // Author(s)     : Michael Hoffmann <hoffmann@inf.ethz.ch>
00023 //                 Lutz Kettner <kettner@mpi-sb.mpg.de>
00024 //                 Sylvain Pion
00025 
00026 #ifndef CGAL_CIRCULATOR_PROJECT_H
00027 #define CGAL_CIRCULATOR_PROJECT_H 1
00028 
00029 #include <CGAL/circulator.h>
00030 
00031 CGAL_BEGIN_NAMESPACE
00032 
00033 template < class C,
00034            class Fct,
00035            class Ref = typename C::reference,
00036            class Ptr = typename C::pointer>
00037 class Circulator_project {
00038 protected:
00039   C        nt;    // The internal circulator.
00040 public:
00041   typedef C  Circulator;
00042   typedef Circulator_project<C,Fct,Ref,Ptr> Self;
00043 
00044   typedef typename  C::iterator_category   iterator_category;
00045   typedef typename  Fct::result_type       value_type;
00046   typedef typename  C::difference_type     difference_type;
00047   typedef typename  C::size_type           size_type;
00048   typedef           Ref                    reference;
00049   typedef           Ptr                    pointer;
00050 
00051   // CREATION
00052   // --------
00053 
00054   Circulator_project() {}
00055   Circulator_project( Circulator j) : nt(j) {}
00056 
00057   // OPERATIONS Forward Category
00058   // ---------------------------
00059 
00060   Circulator  current_circulator() const { return nt;}
00061   Ptr ptr() const {
00062     Fct fct;
00063     return &(fct(*nt));
00064   }
00065 
00066   bool operator==( Nullptr_t p) const {
00067     CGAL_assertion( p == 0);
00068     return ( nt == 0);
00069   }
00070   bool  operator!=( Nullptr_t p) const { return !(*this == p); }
00071   bool  operator==( const Self& i) const { return ( nt == i.nt); }
00072   bool  operator!=( const Self& i) const { return !(*this == i); }
00073   Ref   operator*()  const { return *ptr(); }
00074   Ptr   operator->() const { return ptr(); }
00075   Self& operator++() {
00076     ++nt;
00077     return *this;
00078   }
00079   Self  operator++(int) {
00080     Self tmp = *this;
00081     ++*this;
00082     return tmp;
00083   }
00084 
00085   // OPERATIONS Bidirectional Category
00086   // ---------------------------------
00087 
00088   Self& operator--() {
00089     --nt;
00090     return *this;
00091   }
00092   Self  operator--(int) {
00093     Self tmp = *this;
00094     --*this;
00095     return tmp;
00096   }
00097 
00098   // OPERATIONS Random Access Category
00099   // ---------------------------------
00100 
00101   Self  min_circulator() const {
00102     return Self( nt.min_circulator());
00103   }
00104   Self& operator+=( difference_type n) {
00105     nt += n;
00106     return *this;
00107   }
00108   Self  operator+( difference_type n) const {
00109     Self tmp = *this;
00110     return tmp += n;
00111   }
00112   Self& operator-=( difference_type n) {
00113     return operator+=( -n);
00114   }
00115   Self  operator-( difference_type n) const {
00116     Self tmp = *this;
00117     return tmp += -n;
00118   }
00119   difference_type  operator-( const Self& i) const {
00120     return nt - i.nt;
00121   }
00122   Ref  operator[]( difference_type n) const {
00123     Self tmp = *this;
00124     tmp += n;
00125     return tmp.operator*();
00126   }
00127 };
00128 
00129 template < class Dist, class Fct, class C, class Ref, class Ptr>
00130 inline
00131 Circulator_project<C,Fct,Ref,Ptr>
00132 operator+( Dist n, Circulator_project<C,Fct,Ref,Ptr> i) { return i += n; }
00133 
00134 CGAL_END_NAMESPACE
00135 #endif // CGAL_CIRCULATOR_PROJECT_H //
00136 // EOF //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines