deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
synchronous_iterator.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2009 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_synchronous_iterator_h
14#define dealii_synchronous_iterator_h
15
16
17#include <deal.II/base/config.h>
18
20
21#include <iterator>
22#include <tuple>
23
25
46template <typename Iterators>
48{
52 SynchronousIterators(const Iterators &i);
53
58 const Iterators &
59 operator*() const;
60
65 Iterators &
66 operator*();
67
72 using difference_type = std::size_t;
73 using iterator_category = std::bidirectional_iterator_tag;
74 using value_type = Iterators;
75 using pointer = Iterators *;
76 using reference = Iterators &;
77
78private:
82 Iterators iterators;
83};
84
85
86
87template <typename Iterators>
89 : iterators(i)
90{}
91
92
93
94template <typename Iterators>
95inline const Iterators &
97{
98 return iterators;
99}
100
101
102
103template <typename Iterators>
104inline Iterators &
106{
107 return iterators;
108}
109
110
111
120template <typename Iterators>
121inline bool
124{
125 return std::get<0>(*a) < std::get<0>(*b);
126}
127
128
129
137template <typename Iterators>
138inline std::size_t
141{
142 Assert(std::distance(std::get<0>(*b), std::get<0>(*a)) >= 0,
144 return std::distance(std::get<0>(*b), std::get<0>(*a));
145}
146
147
153template <typename I1, typename I2>
154inline void
155advance(std::tuple<I1, I2> &t, const unsigned int n)
156{
157 std::advance(std::get<0>(t), n);
158 std::advance(std::get<1>(t), n);
159}
160
166template <typename I1, typename I2, typename I3>
167inline void
168advance(std::tuple<I1, I2, I3> &t, const unsigned int n)
169{
170 std::advance(std::get<0>(t), n);
171 std::advance(std::get<1>(t), n);
172 std::advance(std::get<2>(t), n);
173}
174
180template <typename I1, typename I2, typename I3, typename I4>
181inline void
182advance(std::tuple<I1, I2, I3, I4> &t, const unsigned int n)
183{
184 std::advance(std::get<0>(t), n);
185 std::advance(std::get<1>(t), n);
186 std::advance(std::get<2>(t), n);
187 std::advance(std::get<3>(t), n);
188}
189
195template <typename I1, typename I2>
196inline void
197prev(std::tuple<I1, I2> &t)
198{
199 --std::get<0>(t);
200 --std::get<1>(t);
201}
202
208template <typename I1, typename I2, typename I3>
209inline void
210prev(std::tuple<I1, I2, I3> &t)
211{
212 --std::get<0>(t);
213 --std::get<1>(t);
214 --std::get<2>(t);
215}
216
222template <typename I1, typename I2, typename I3, typename I4>
223inline void
224prev(std::tuple<I1, I2, I3, I4> &t)
225{
226 --std::get<0>(t);
227 --std::get<1>(t);
228 --std::get<2>(t);
229 --std::get<3>(t);
230}
231
237template <typename I1, typename I2>
238inline void
239advance_by_one(std::tuple<I1, I2> &t)
240{
241 ++std::get<0>(t);
242 ++std::get<1>(t);
243}
244
250template <typename I1, typename I2, typename I3>
251inline void
252advance_by_one(std::tuple<I1, I2, I3> &t)
253{
254 ++std::get<0>(t);
255 ++std::get<1>(t);
256 ++std::get<2>(t);
257}
258
264template <typename I1, typename I2, typename I3, typename I4>
265inline void
266advance_by_one(std::tuple<I1, I2, I3, I4> &t)
267{
268 ++std::get<0>(t);
269 ++std::get<1>(t);
270 ++std::get<2>(t);
271 ++std::get<3>(t);
272}
273
279template <typename Iterators>
281operator+(const SynchronousIterators<Iterators> &a, const std::size_t n)
282{
284 ::advance(*x, n);
285 return x;
286}
287
293template <typename Iterators>
300
306template <typename Iterators>
309{
310 ::prev(*a);
311 return a;
312}
313
319template <typename Iterators>
327
334template <typename Iterators>
335inline bool
338{
339 return (std::get<0>(*a) != std::get<0>(*b));
340}
341
343
344#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
void advance_by_one(std::tuple< I1, I2, I3 > &t)
void prev(std::tuple< I1, I2, I3, I4 > &t)
bool operator!=(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance(std::tuple< I1, I2, I3, I4 > &t, const unsigned int n)
SynchronousIterators< Iterators > operator+(const SynchronousIterators< Iterators > &a, const std::size_t n)
std::size_t operator-(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance(std::tuple< I1, I2, I3 > &t, const unsigned int n)
SynchronousIterators(const Iterators &i)
SynchronousIterators< Iterators > & operator--(SynchronousIterators< Iterators > &a)
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
std::bidirectional_iterator_tag iterator_category
void advance_by_one(std::tuple< I1, I2 > &t)
void prev(std::tuple< I1, I2, I3 > &t)
SynchronousIterators< Iterators > & operator++(SynchronousIterators< Iterators > &a)
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a, int)
const Iterators & operator*() const
void advance_by_one(std::tuple< I1, I2, I3, I4 > &t)
void prev(std::tuple< I1, I2 > &t)
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
void advance_by_one(std::tuple< I1, I2 > &t)
void prev(std::tuple< I1, I2 > &t)