Reference documentation for deal.II version 9.0.0
synchronous_iterator.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_synchronous_iterator_h
17 #define dealii_synchronous_iterator_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 
23 
24 #include <iterator>
25 #include <tuple>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
51 template <typename Iterators>
53 {
57  SynchronousIterators (const Iterators &i);
58 
63  const Iterators &operator* () const;
64 
69  Iterators &operator* ();
70 
71 private:
75  Iterators iterators;
76 };
77 
78 
79 
80 template <typename Iterators>
81 inline
83 SynchronousIterators (const Iterators &i)
84  :
85  iterators (i)
86 {}
87 
88 
89 
90 template <typename Iterators>
91 inline
92 const Iterators &
94 {
95  return iterators;
96 }
97 
98 
99 
100 template <typename Iterators>
101 inline
102 Iterators &
104 {
105  return iterators;
106 }
107 
108 
109 
118 template <typename Iterators>
119 inline
120 bool
121 operator< (const SynchronousIterators<Iterators> &a,
123 {
124  return std::get<0>(*a) < std::get<0>(*b);
125 }
126 
127 
128 
136 template <typename Iterators>
137 inline
138 std::size_t
141 {
142  Assert (std::distance (std::get<0>(*b),
143  std::get<0>(*a)) >= 0,
144  ExcInternalError());
145  return std::distance (std::get<0>(*b),
146  std::get<0>(*a));
147 }
148 
149 
155 template <typename I1, typename I2>
156 inline
157 void advance (std::tuple<I1,I2> &t,
158  const unsigned int n)
159 {
160  std::advance (std::get<0>(t), n);
161  std::advance (std::get<1>(t), n);
162 }
163 
169 template <typename I1, typename I2, typename I3>
170 inline
171 void advance (std::tuple<I1,I2,I3> &t,
172  const unsigned int n)
173 {
174  std::advance (std::get<0>(t), n);
175  std::advance (std::get<1>(t), n);
176  std::advance (std::get<2>(t), n);
177 }
178 
184 template <typename I1, typename I2,
185  typename I3, typename I4>
186 inline
187 void advance (std::tuple<I1,I2,I3, I4> &t,
188  const unsigned int n)
189 {
190  std::advance (std::get<0>(t), n);
191  std::advance (std::get<1>(t), n);
192  std::advance (std::get<2>(t), n);
193  std::advance (std::get<3>(t), n);
194 }
195 
196 
197 
203 template <typename I1, typename I2>
204 inline
205 void advance_by_one (std::tuple<I1,I2> &t)
206 {
207  ++std::get<0>(t);
208  ++std::get<1>(t);
209 }
210 
216 template <typename I1, typename I2, typename I3>
217 inline
218 void advance_by_one (std::tuple<I1,I2,I3> &t)
219 {
220  ++std::get<0>(t);
221  ++std::get<1>(t);
222  ++std::get<2>(t);
223 }
224 
230 template <typename I1, typename I2,
231  typename I3, typename I4>
232 inline
233 void advance_by_one (std::tuple<I1,I2,I3,I4> &t)
234 {
235  ++std::get<0>(t);
236  ++std::get<1>(t);
237  ++std::get<2>(t);
238  ++std::get<3>(t);
239 }
240 
241 
242 
248 template <typename Iterators>
249 inline
252  const std::size_t n)
253 {
255  ::advance (*x, n);
256  return x;
257 }
258 
264 template <typename Iterators>
265 inline
268 {
269  ::advance_by_one (*a);
270  return a;
271 }
272 
273 
280 template <typename Iterators>
281 inline
282 bool
285 {
286  return (std::get<0>(*a) !=
287  std::get<0>(*b));
288 }
289 
290 DEAL_II_NAMESPACE_CLOSE
291 
292 #endif
void advance(std::tuple< I1, I2, I3 > &t, const unsigned int n)
void advance_by_one(std::tuple< I1, I2, I3 > &t)
SymmetricTensor< rank_, dim, typename ProductType< Number, OtherNumber >::type > operator+(const SymmetricTensor< rank_, dim, Number > &left, const SymmetricTensor< rank_, dim, OtherNumber > &right)
void advance(std::tuple< I1, I2, I3, I4 > &t, const unsigned int n)
SymmetricTensor< rank_, dim, typename ProductType< Number, OtherNumber >::type > operator-(const SymmetricTensor< rank_, dim, Number > &left, const SymmetricTensor< rank_, dim, OtherNumber > &right)
void advance_by_one(std::tuple< I1, I2 > &t)
#define Assert(cond, exc)
Definition: exceptions.h:1142
SynchronousIterators(const Iterators &i)
void advance_by_one(std::tuple< I1, I2, I3, I4 > &t)
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a)
bool operator!=(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
const Iterators & operator*() const
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
static ::ExceptionBase & ExcInternalError()