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