STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
iterator.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 // Copyright (C) 2007-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
9 // version.
10 
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
30 // Written by Johannes Singler.
31 
32 #ifndef _GLIBCXX_PARALLEL_ITERATOR_H
33 #define _GLIBCXX_PARALLEL_ITERATOR_H 1
34 
36 #include <bits/stl_pair.h>
37 
38 namespace __gnu_parallel
39 {
43  template<typename _Iterator1, typename _Iterator2,
44  typename _IteratorCategory>
45  class _IteratorPair : public std::pair<_Iterator1, _Iterator2>
46  {
47  private:
48  typedef std::pair<_Iterator1, _Iterator2> _Base;
49 
50  public:
51  typedef _IteratorCategory iterator_category;
52  typedef void value_type;
53 
54  typedef std::iterator_traits<_Iterator1> _TraitsType;
55  typedef typename _TraitsType::difference_type difference_type;
58 
60 
61  _IteratorPair(const _Iterator1& __first, const _Iterator2& __second)
62  : _Base(__first, __second) { }
63 
64  // Pre-increment operator.
67  {
68  ++_Base::first;
69  ++_Base::second;
70  return *this;
71  }
72 
73  // Post-increment operator.
74  const _IteratorPair
76  { return _IteratorPair(_Base::first++, _Base::second++); }
77 
78  // Pre-decrement operator.
81  {
82  --_Base::first;
83  --_Base::second;
84  return *this;
85  }
86 
87  // Post-decrement operator.
88  const _IteratorPair
90  { return _IteratorPair(_Base::first--, _Base::second--); }
91 
92  // Type conversion.
93  operator _Iterator2() const
94  { return _Base::second; }
95 
97  operator=(const _IteratorPair& __other)
98  {
99  _Base::first = __other.first;
100  _Base::second = __other.second;
101  return *this;
102  }
103 
105  operator+(difference_type __delta) const
106  { return _IteratorPair(_Base::first + __delta, _Base::second + __delta);
107  }
108 
110  operator-(const _IteratorPair& __other) const
111  { return _Base::first - __other.first; }
112  };
113 
114 
118  template<typename _Iterator1, typename _Iterator2, typename _Iterator3,
119  typename _IteratorCategory>
121  {
122  public:
123  typedef _IteratorCategory iterator_category;
124  typedef void value_type;
125  typedef typename std::iterator_traits<_Iterator1>::difference_type
129 
130  _Iterator1 _M_first;
131  _Iterator2 _M_second;
132  _Iterator3 _M_third;
133 
135 
136  _IteratorTriple(const _Iterator1& __first, const _Iterator2& __second,
137  const _Iterator3& __third)
138  {
139  _M_first = __first;
140  _M_second = __second;
141  _M_third = __third;
142  }
143 
144  // Pre-increment operator.
147  {
148  ++_M_first;
149  ++_M_second;
150  ++_M_third;
151  return *this;
152  }
153 
154  // Post-increment operator.
155  const _IteratorTriple
157  { return _IteratorTriple(_M_first++, _M_second++, _M_third++); }
158 
159  // Pre-decrement operator.
162  {
163  --_M_first;
164  --_M_second;
165  --_M_third;
166  return *this;
167  }
168 
169  // Post-decrement operator.
170  const _IteratorTriple
172  { return _IteratorTriple(_M_first--, _M_second--, _M_third--); }
173 
174  // Type conversion.
175  operator _Iterator3() const
176  { return _M_third; }
177 
179  operator=(const _IteratorTriple& __other)
180  {
181  _M_first = __other._M_first;
182  _M_second = __other._M_second;
183  _M_third = __other._M_third;
184  return *this;
185  }
186 
188  operator+(difference_type __delta) const
189  { return _IteratorTriple(_M_first + __delta, _M_second + __delta,
190  _M_third + __delta); }
191 
193  operator-(const _IteratorTriple& __other) const
194  { return _M_first - __other._M_first; }
195  };
196 }
197 
198 #endif /* _GLIBCXX_PARALLEL_ITERATOR_H */
_Iterator3 _M_third
Definition: iterator.h:132
_IteratorTriple & operator--()
Definition: iterator.h:161
const _IteratorTriple operator++(int)
Definition: iterator.h:156
A pair of iterators. The usual iterator operations are applied to both child iterators.
Definition: iterator.h:45
const _IteratorPair operator--(int)
Definition: iterator.h:89
_Iterator2 _M_second
Definition: iterator.h:131
std::iterator_traits< _Iterator1 >::difference_type difference_type
Definition: iterator.h:126
_IteratorPair * pointer
Definition: iterator.h:56
_Iterator1 _M_first
Definition: iterator.h:130
_IteratorTriple & operator++()
Definition: iterator.h:146
_IteratorTriple()
Definition: iterator.h:134
_IteratorPair & reference
Definition: iterator.h:57
difference_type operator-(const _IteratorPair &__other) const
Definition: iterator.h:110
A triple of iterators. The usual iterator operations are applied to all three child iterators...
Definition: iterator.h:120
Includes the original header files concerned with iterators except for stream iterators. This file is a GNU parallel extension to the Standard C++ Library.
void value_type
Definition: iterator.h:52
difference_type operator-(const _IteratorTriple &__other) const
Definition: iterator.h:193
std::pair< _Iterator1, _Iterator2 > _Base
Definition: iterator.h:48
_TraitsType::difference_type difference_type
Definition: iterator.h:55
_IteratorTriple & reference
Definition: iterator.h:128
_IteratorCategory iterator_category
Definition: iterator.h:51
void value_type
Definition: iterator.h:124
_IteratorTriple & operator=(const _IteratorTriple &__other)
Definition: iterator.h:179
std::iterator_traits< _Iterator1 > _TraitsType
Definition: iterator.h:54
_IteratorPair & operator=(const _IteratorPair &__other)
Definition: iterator.h:97
_IteratorTriple operator+(difference_type __delta) const
Definition: iterator.h:188
_IteratorTriple * pointer
Definition: iterator.h:127
_IteratorTriple(const _Iterator1 &__first, const _Iterator2 &__second, const _Iterator3 &__third)
Definition: iterator.h:136
_IteratorPair & operator++()
Definition: iterator.h:66
_IteratorCategory iterator_category
Definition: iterator.h:123
_IteratorPair & operator--()
Definition: iterator.h:80
const _IteratorTriple operator--(int)
Definition: iterator.h:171
_IteratorPair(const _Iterator1 &__first, const _Iterator2 &__second)
Definition: iterator.h:61
_IteratorPair()
Definition: iterator.h:59
const _IteratorPair operator++(int)
Definition: iterator.h:75
_IteratorPair operator+(difference_type __delta) const
Definition: iterator.h:105