BWAPI
|
00001 // Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Nef_2/include/CGAL/Nef_2/iterator_tools.h $ 00015 // $Id: iterator_tools.h 44130 2008-07-12 21:58:52Z spion $ 00016 // 00017 // 00018 // Author(s) : Michael Seel <seel@mpi-sb.mpg.de> 00019 #ifndef CGAL_ITERATORTOOLS_H 00020 #define CGAL_ITERATORTOOLS_H 00021 00022 #include <CGAL/basic.h> 00023 #include <CGAL/circulator.h> 00024 00025 CGAL_BEGIN_NAMESPACE 00026 00027 template <typename Iter, typename Move> 00028 class CircFromIt : public Iter { 00029 // Ptr node; // The internal node ptr inherited from It. 00030 typedef CircFromIt<Iter,Move> Self; 00031 public: 00032 typedef typename Iter::iterator_category Icategory; 00033 typedef I_Circulator_from_iterator_traits<Icategory> CTraits; 00034 typedef typename CTraits::iterator_category iterator_category; 00035 00036 CircFromIt() : Iter(0) {} 00037 CircFromIt(Iter i) : Iter(i) {} 00038 00039 // OPERATIONS Forward Category 00040 // --------------------------- 00041 00042 bool operator==( Nullptr_t p ) const { 00043 CGAL_assertion( p == NULL ); 00044 return Iter::operator==( Iter(NULL) ); 00045 } 00046 bool operator!=( Nullptr_t p ) const { 00047 return !(*this == p); 00048 } 00049 bool operator==( const Self& i ) const { 00050 return Iter::operator==(i); 00051 } 00052 bool operator!=( const Self& i) const { 00053 return !(*this == i); 00054 } 00055 00056 Self& operator++() { 00057 Move move; 00058 move.forward(*this); 00059 return *this; 00060 } 00061 Self operator++(int) { 00062 CircFromIt tmp = *this; 00063 ++*this; 00064 return tmp; 00065 } 00066 00067 // OPERATIONS Bidirectional Category 00068 // --------------------------------- 00069 00070 Self& operator--() { 00071 Move move; 00072 move.backward(*this); 00073 return *this; 00074 } 00075 Self operator--(int) { 00076 CircFromIt tmp = *this; 00077 --*this; 00078 return tmp; 00079 } 00080 00081 }; 00082 00083 template <typename Iter, typename Pnt> 00084 class PntItFromVertIt : public Iter { 00085 public: 00086 typedef PntItFromVertIt<Iter,Pnt> Self; 00087 typedef Iter Base; 00088 typedef Pnt value_type; 00089 typedef const Pnt* pointer; 00090 typedef const Pnt& reference; 00091 00092 PntItFromVertIt() : Base() {} 00093 PntItFromVertIt(Iter it) : Base(it) {} 00094 PntItFromVertIt(const Self& it) : Base(it) {} 00095 00096 reference operator*() const 00097 { return Base::operator*().point(); } 00098 pointer operator->() const 00099 { return &(operator*()); } 00100 Self& operator++() { return (Self&)Base::operator++(); } 00101 Self operator++(int) { Self tmp=*this; ++*this; return tmp; } 00102 00103 }; 00104 00105 template <class H> 00106 std::string PH(H h) 00107 { if (h == H()) return "nil"; return h->debug(); } 00108 00109 CGAL_END_NAMESPACE 00110 #endif // CGAL_ITERATORTOOLS_H