deal.II version GIT relicensing-2353-g6beaff027c 2025-01-15 01:10:00+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: LGPL-2.1-or-later
4// Copyright (C) 2009 - 2021 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_synchronous_iterator_h
16#define dealii_synchronous_iterator_h
17
18
19#include <deal.II/base/config.h>
20
22
23#include <iterator>
24#include <tuple>
25
27
48template <typename Iterators>
50{
54 SynchronousIterators(const Iterators &i);
55
60 const Iterators &
61 operator*() const;
62
67 Iterators &
68 operator*();
69
74 using difference_type = std::size_t;
75 using iterator_category = std::bidirectional_iterator_tag;
76 using value_type = Iterators;
77 using pointer = Iterators *;
78 using reference = Iterators &;
79
80private:
84 Iterators iterators;
85};
86
87
88
89template <typename Iterators>
91 : iterators(i)
92{}
93
94
95
96template <typename Iterators>
97inline const Iterators &
99{
100 return iterators;
101}
102
103
104
105template <typename Iterators>
106inline Iterators &
108{
109 return iterators;
110}
111
112
113
122template <typename Iterators>
123inline bool
126{
127 return std::get<0>(*a) < std::get<0>(*b);
128}
129
130
131
139template <typename Iterators>
140inline std::size_t
143{
144 Assert(std::distance(std::get<0>(*b), std::get<0>(*a)) >= 0,
146 return std::distance(std::get<0>(*b), std::get<0>(*a));
147}
148
149
155template <typename I1, typename I2>
156inline void
157advance(std::tuple<I1, I2> &t, const unsigned int n)
158{
159 std::advance(std::get<0>(t), n);
160 std::advance(std::get<1>(t), n);
161}
162
168template <typename I1, typename I2, typename I3>
169inline void
170advance(std::tuple<I1, I2, I3> &t, const unsigned int n)
171{
172 std::advance(std::get<0>(t), n);
173 std::advance(std::get<1>(t), n);
174 std::advance(std::get<2>(t), n);
175}
176
182template <typename I1, typename I2, typename I3, typename I4>
183inline void
184advance(std::tuple<I1, I2, I3, I4> &t, const unsigned int n)
185{
186 std::advance(std::get<0>(t), n);
187 std::advance(std::get<1>(t), n);
188 std::advance(std::get<2>(t), n);
189 std::advance(std::get<3>(t), n);
190}
191
197template <typename I1, typename I2>
198inline void
199prev(std::tuple<I1, I2> &t)
200{
201 --std::get<0>(t);
202 --std::get<1>(t);
203}
204
210template <typename I1, typename I2, typename I3>
211inline void
212prev(std::tuple<I1, I2, I3> &t)
213{
214 --std::get<0>(t);
215 --std::get<1>(t);
216 --std::get<2>(t);
217}
218
224template <typename I1, typename I2, typename I3, typename I4>
225inline void
226prev(std::tuple<I1, I2, I3, I4> &t)
227{
228 --std::get<0>(t);
229 --std::get<1>(t);
230 --std::get<2>(t);
231 --std::get<3>(t);
232}
233
239template <typename I1, typename I2>
240inline void
241advance_by_one(std::tuple<I1, I2> &t)
242{
243 ++std::get<0>(t);
244 ++std::get<1>(t);
245}
246
252template <typename I1, typename I2, typename I3>
253inline void
254advance_by_one(std::tuple<I1, I2, I3> &t)
255{
256 ++std::get<0>(t);
257 ++std::get<1>(t);
258 ++std::get<2>(t);
259}
260
266template <typename I1, typename I2, typename I3, typename I4>
267inline void
268advance_by_one(std::tuple<I1, I2, I3, I4> &t)
269{
270 ++std::get<0>(t);
271 ++std::get<1>(t);
272 ++std::get<2>(t);
273 ++std::get<3>(t);
274}
275
281template <typename Iterators>
283operator+(const SynchronousIterators<Iterators> &a, const std::size_t n)
284{
286 ::advance(*x, n);
287 return x;
288}
289
295template <typename Iterators>
302
308template <typename Iterators>
311{
312 ::prev(*a);
313 return a;
314}
315
321template <typename Iterators>
329
336template <typename Iterators>
337inline bool
340{
341 return (std::get<0>(*a) != std::get<0>(*b));
342}
343
345
346#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#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)