00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 #ifndef SGI_iterator_adapter_h_INCLUDED 00038 #define SGI_iterator_adapter_h_INCLUDED 00039 00040 #include <iterator> 00041 00042 namespace SGI { 00043 00044 template <class Iterator> 00045 class const_iterator { 00046 protected: 00047 Iterator current; 00048 00049 public: 00050 typedef typename iterator_traits<Iterator>::iterator_category iterator_category; 00051 typedef typename iterator_traits<Iterator>::value_type value_type; 00052 typedef typename iterator_traits<Iterator>::difference_type difference_type; 00053 typedef typename iterator_traits<Iterator>::pointer pointer; 00054 typedef const iterator_traits<Iterator>::value_type& reference; 00055 typedef const iterator_traits<Iterator>::value_type& const_reference; 00056 typedef Iterator iterator_type; 00057 typedef const_iterator<Iterator> self; 00058 00059 const_iterator() {} 00060 explicit const_iterator(iterator_type x) : current(x) {} 00061 00062 const_iterator(const self& x) : current(x.current) {} 00063 template <class Iter> 00064 const_iterator(const const_iterator<Iter>& x) : current(x.current) {} 00065 00066 iterator_type base() const { return current; } 00067 const_reference operator*() const { 00068 return *current; 00069 } 00070 pointer operator->() const { return &(operator*()); } 00071 00072 self& operator++() { 00073 ++current; 00074 return *this; 00075 } 00076 self operator++(int) { 00077 self tmp = *this; 00078 ++current; 00079 return tmp; 00080 } 00081 self& operator--() { 00082 --current; 00083 return *this; 00084 } 00085 self operator--(int) { 00086 self tmp = *this; 00087 --current; 00088 return tmp; 00089 } 00090 00091 self operator+(difference_type n) const { 00092 return self(current + n); 00093 } 00094 self operator-(difference_type n) const { 00095 return self(current - n); 00096 } 00097 difference_type operator-(self n) const { 00098 return difference_type(current - n.current); 00099 } 00100 self& operator+=(difference_type n) { 00101 current += n; 00102 return *this; 00103 } 00104 self& operator-=(difference_type n) { 00105 current -= n; 00106 return *this; 00107 } 00108 const_reference operator[](difference_type n) const { return *(*this + n); } 00109 }; 00110 00111 } // Close namespace SGI 00112 00113 #endif /* SGI_iterator_adapter_h_INCLUDE */ 00114 00115 // Local Variables: 00116 // mode:C++ 00117 // End:
1.5.6