iterator.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _GLIBCXX_PARALLEL_ITERATOR_H
00039 #define _GLIBCXX_PARALLEL_ITERATOR_H 1
00040
00041 #include <parallel/basic_iterator.h>
00042 #include <bits/stl_pair.h>
00043
00044 namespace __gnu_parallel
00045 {
00046
00047
00048
00049 template<typename Iterator1, typename Iterator2, typename IteratorCategory>
00050 class iterator_pair : public std::pair<Iterator1, Iterator2>
00051 {
00052 private:
00053 typedef iterator_pair<Iterator1, Iterator2, IteratorCategory> type;
00054 typedef std::pair<Iterator1, Iterator2> base_type;
00055
00056 public:
00057 typedef IteratorCategory iterator_category;
00058 typedef void value_type;
00059
00060 typedef std::iterator_traits<Iterator1> traits_type;
00061 typedef typename traits_type::difference_type difference_type;
00062 typedef type* pointer;
00063 typedef type& reference;
00064
00065 iterator_pair() { }
00066
00067 iterator_pair(const Iterator1& first, const Iterator2& second)
00068 : base_type(first, second) { }
00069
00070
00071 type&
00072 operator++()
00073 {
00074 ++base_type::first;
00075 ++base_type::second;
00076 return *this;
00077 }
00078
00079
00080 const type
00081 operator++(int)
00082 { return type(base_type::first++, base_type::second++); }
00083
00084
00085 type&
00086 operator--()
00087 {
00088 --base_type::first;
00089 --base_type::second;
00090 return *this;
00091 }
00092
00093
00094 const type
00095 operator--(int)
00096 { return type(base_type::first--, base_type::second--); }
00097
00098
00099 operator Iterator2() const
00100 { return base_type::second; }
00101
00102 type&
00103 operator=(const type& other)
00104 {
00105 base_type::first = other.first;
00106 base_type::second = other.second;
00107 return *this;
00108 }
00109
00110 type
00111 operator+(difference_type delta) const
00112 { return type(base_type::first + delta, base_type::second + delta); }
00113
00114 difference_type
00115 operator-(const type& other) const
00116 { return base_type::first - other.first; }
00117 };
00118
00119
00120
00121
00122
00123 template<typename Iterator1, typename Iterator2, typename Iterator3,
00124 typename IteratorCategory>
00125 class iterator_triple
00126 {
00127 private:
00128 typedef iterator_triple<Iterator1, Iterator2, Iterator3,
00129 IteratorCategory> type;
00130
00131 public:
00132 typedef IteratorCategory iterator_category;
00133 typedef void value_type;
00134 typedef typename Iterator1::difference_type difference_type;
00135 typedef type* pointer;
00136 typedef type& reference;
00137
00138 Iterator1 first;
00139 Iterator2 second;
00140 Iterator3 third;
00141
00142 iterator_triple() { }
00143
00144 iterator_triple(const Iterator1& _first, const Iterator2& _second,
00145 const Iterator3& _third)
00146 {
00147 first = _first;
00148 second = _second;
00149 third = _third;
00150 }
00151
00152
00153 type&
00154 operator++()
00155 {
00156 ++first;
00157 ++second;
00158 ++third;
00159 return *this;
00160 }
00161
00162
00163 const type
00164 operator++(int)
00165 { return type(first++, second++, third++); }
00166
00167
00168 type&
00169 operator--()
00170 {
00171 --first;
00172 --second;
00173 --third;
00174 return *this;
00175 }
00176
00177
00178 const type
00179 operator--(int)
00180 { return type(first--, second--, third--); }
00181
00182
00183 operator Iterator3() const
00184 { return third; }
00185
00186 type&
00187 operator=(const type& other)
00188 {
00189 first = other.first;
00190 second = other.second;
00191 third = other.third;
00192 return *this;
00193 }
00194
00195 type
00196 operator+(difference_type delta) const
00197 { return type(first + delta, second + delta, third + delta); }
00198
00199 difference_type
00200 operator-(const type& other) const
00201 { return first - other.first; }
00202 };
00203 }
00204
00205 #endif