Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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.md at
12 // the top level directory of deal.II.
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 
22 #include <deal.II/base/exceptions.h>
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>
82  : iterators(i)
83 {}
84 
85 
86 
87 template <typename Iterators>
88 inline const Iterators &SynchronousIterators<Iterators>::operator*() const
89 {
90  return iterators;
91 }
92 
93 
94 
95 template <typename Iterators>
97 {
98  return iterators;
99 }
100 
101 
102 
111 template <typename Iterators>
112 inline bool
113 operator<(const SynchronousIterators<Iterators> &a,
115 {
116  return std::get<0>(*a) < std::get<0>(*b);
117 }
118 
119 
120 
128 template <typename Iterators>
129 inline std::size_t
132 {
133  Assert(std::distance(std::get<0>(*b), std::get<0>(*a)) >= 0,
134  ExcInternalError());
135  return std::distance(std::get<0>(*b), std::get<0>(*a));
136 }
137 
138 
144 template <typename I1, typename I2>
145 inline void
146 advance(std::tuple<I1, I2> &t, const unsigned int n)
147 {
148  std::advance(std::get<0>(t), n);
149  std::advance(std::get<1>(t), n);
150 }
151 
157 template <typename I1, typename I2, typename I3>
158 inline void
159 advance(std::tuple<I1, I2, I3> &t, const unsigned int n)
160 {
161  std::advance(std::get<0>(t), n);
162  std::advance(std::get<1>(t), n);
163  std::advance(std::get<2>(t), n);
164 }
165 
171 template <typename I1, typename I2, typename I3, typename I4>
172 inline void
173 advance(std::tuple<I1, I2, I3, I4> &t, const unsigned int n)
174 {
175  std::advance(std::get<0>(t), n);
176  std::advance(std::get<1>(t), n);
177  std::advance(std::get<2>(t), n);
178  std::advance(std::get<3>(t), n);
179 }
180 
181 
182 
188 template <typename I1, typename I2>
189 inline void
190 advance_by_one(std::tuple<I1, I2> &t)
191 {
192  ++std::get<0>(t);
193  ++std::get<1>(t);
194 }
195 
201 template <typename I1, typename I2, typename I3>
202 inline void
203 advance_by_one(std::tuple<I1, I2, I3> &t)
204 {
205  ++std::get<0>(t);
206  ++std::get<1>(t);
207  ++std::get<2>(t);
208 }
209 
215 template <typename I1, typename I2, typename I3, typename I4>
216 inline void
217 advance_by_one(std::tuple<I1, I2, I3, I4> &t)
218 {
219  ++std::get<0>(t);
220  ++std::get<1>(t);
221  ++std::get<2>(t);
222  ++std::get<3>(t);
223 }
224 
225 
226 
232 template <typename Iterators>
234 operator+(const SynchronousIterators<Iterators> &a, const std::size_t n)
235 {
237  ::advance(*x, n);
238  return x;
239 }
240 
246 template <typename Iterators>
249 {
250  ::advance_by_one(*a);
251  return a;
252 }
253 
254 
261 template <typename Iterators>
262 inline bool
265 {
266  return (std::get<0>(*a) != std::get<0>(*b));
267 }
268 
269 DEAL_II_NAMESPACE_CLOSE
270 
271 #endif
void advance(std::tuple< I1, I2, I3 > &t, const unsigned int n)
void advance_by_one(std::tuple< I1, I2, I3 > &t)
std::size_t operator-(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance(std::tuple< I1, I2, I3, I4 > &t, const unsigned int n)
void advance_by_one(std::tuple< I1, I2 > &t)
#define Assert(cond, exc)
Definition: exceptions.h:1407
SynchronousIterators(const Iterators &i)
void advance_by_one(std::tuple< I1, I2, I3, I4 > &t)
SynchronousIterators< Iterators > operator+(const SynchronousIterators< Iterators > &a, const std::size_t n)
bool operator!=(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a)
const Iterators & operator*() const
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
static ::ExceptionBase & ExcInternalError()