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 std::iterator_traits<Iterator1>::difference_type
00135 difference_type;
00136 typedef type* pointer;
00137 typedef type& reference;
00138
00139 Iterator1 first;
00140 Iterator2 second;
00141 Iterator3 third;
00142
00143 iterator_triple() { }
00144
00145 iterator_triple(const Iterator1& _first, const Iterator2& _second,
00146 const Iterator3& _third)
00147 {
00148 first = _first;
00149 second = _second;
00150 third = _third;
00151 }
00152
00153
00154 type&
00155 operator++()
00156 {
00157 ++first;
00158 ++second;
00159 ++third;
00160 return *this;
00161 }
00162
00163
00164 const type
00165 operator++(int)
00166 { return type(first++, second++, third++); }
00167
00168
00169 type&
00170 operator--()
00171 {
00172 --first;
00173 --second;
00174 --third;
00175 return *this;
00176 }
00177
00178
00179 const type
00180 operator--(int)
00181 { return type(first--, second--, third--); }
00182
00183
00184 operator Iterator3() const
00185 { return third; }
00186
00187 type&
00188 operator=(const type& other)
00189 {
00190 first = other.first;
00191 second = other.second;
00192 third = other.third;
00193 return *this;
00194 }
00195
00196 type
00197 operator+(difference_type delta) const
00198 { return type(first + delta, second + delta, third + delta); }
00199
00200 difference_type
00201 operator-(const type& other) const
00202 { return first - other.first; }
00203 };
00204 }
00205
00206 #endif