Reference documentation for deal.II version Git 497f915867 2021-09-17 22:46:48 +0200
\(\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\}}\)
synchronous_iterator.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2020 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 
23 
24 #include <iterator>
25 #include <tuple>
26 
28 
49 template <typename Iterators>
51 {
55  SynchronousIterators(const Iterators &i);
56 
61  const Iterators &
62  operator*() const;
63 
68  Iterators &
69  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 &
90 {
91  return iterators;
92 }
93 
94 
95 
96 template <typename Iterators>
97 inline Iterators &
99 {
100  return iterators;
101 }
102 
103 
104 
113 template <typename Iterators>
114 inline bool
115 operator<(const SynchronousIterators<Iterators> &a,
117 {
118  return std::get<0>(*a) < std::get<0>(*b);
119 }
120 
121 
122 
130 template <typename Iterators>
131 inline std::size_t
134 {
135  Assert(std::distance(std::get<0>(*b), std::get<0>(*a)) >= 0,
136  ExcInternalError());
137  return std::distance(std::get<0>(*b), std::get<0>(*a));
138 }
139 
140 
146 template <typename I1, typename I2>
147 inline void
148 advance(std::tuple<I1, I2> &t, const unsigned int n)
149 {
150  std::advance(std::get<0>(t), n);
151  std::advance(std::get<1>(t), n);
152 }
153 
159 template <typename I1, typename I2, typename I3>
160 inline void
161 advance(std::tuple<I1, I2, I3> &t, const unsigned int n)
162 {
163  std::advance(std::get<0>(t), n);
164  std::advance(std::get<1>(t), n);
165  std::advance(std::get<2>(t), n);
166 }
167 
173 template <typename I1, typename I2, typename I3, typename I4>
174 inline void
175 advance(std::tuple<I1, I2, I3, I4> &t, const unsigned int n)
176 {
177  std::advance(std::get<0>(t), n);
178  std::advance(std::get<1>(t), n);
179  std::advance(std::get<2>(t), n);
180  std::advance(std::get<3>(t), n);
181 }
182 
183 
184 
190 template <typename I1, typename I2>
191 inline void
192 advance_by_one(std::tuple<I1, I2> &t)
193 {
194  ++std::get<0>(t);
195  ++std::get<1>(t);
196 }
197 
203 template <typename I1, typename I2, typename I3>
204 inline void
205 advance_by_one(std::tuple<I1, I2, I3> &t)
206 {
207  ++std::get<0>(t);
208  ++std::get<1>(t);
209  ++std::get<2>(t);
210 }
211 
217 template <typename I1, typename I2, typename I3, typename I4>
218 inline void
219 advance_by_one(std::tuple<I1, I2, I3, I4> &t)
220 {
221  ++std::get<0>(t);
222  ++std::get<1>(t);
223  ++std::get<2>(t);
224  ++std::get<3>(t);
225 }
226 
227 
228 
234 template <typename Iterators>
236 operator+(const SynchronousIterators<Iterators> &a, const std::size_t n)
237 {
239  ::advance(*x, n);
240  return x;
241 }
242 
248 template <typename Iterators>
251 {
252  ::advance_by_one(*a);
253  return a;
254 }
255 
256 
263 template <typename Iterators>
264 inline bool
267 {
268  return (std::get<0>(*a) != std::get<0>(*b));
269 }
270 
272 
273 #endif
std::size_t operator-(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance_by_one(std::tuple< I1, I2 > &t)
#define Assert(cond, exc)
Definition: exceptions.h:1461
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
SynchronousIterators(const Iterators &i)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
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)
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
const Iterators & operator*() const
void advance(std::tuple< I1, I2 > &t, const unsigned int n)
static ::ExceptionBase & ExcInternalError()