Reference documentation for deal.II version 8.4.2
synchronous_iterator.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2008 - 2016 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 #include <deal.II/base/std_cxx11/tuple.h>
24 
25 #include <iterator>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
50 template <typename Iterators>
52 {
56  SynchronousIterators (const Iterators &i);
57 
62 
66  Iterators iterators;
67 };
68 
69 
70 
71 template <typename Iterators>
72 inline
74 SynchronousIterators (const Iterators &i)
75  :
76  iterators (i)
77 {}
78 
79 
80 template <typename Iterators>
81 inline
84  :
86 {}
87 
88 
89 
98 template <typename Iterators>
99 inline
100 bool
101 operator< (const SynchronousIterators<Iterators> &a,
103 {
104  return std_cxx11::get<0>(a.iterators) < std_cxx11::get<0>(b.iterators);
105 }
106 
107 
108 
116 template <typename Iterators>
117 inline
118 std::size_t
121 {
122  Assert (std::distance (std_cxx11::get<0>(b.iterators),
123  std_cxx11::get<0>(a.iterators)) >= 0,
124  ExcInternalError());
125  return std::distance (std_cxx11::get<0>(b.iterators),
126  std_cxx11::get<0>(a.iterators));
127 }
128 
129 
135 template <typename I1, typename I2>
136 inline
137 void advance (std_cxx11::tuple<I1,I2> &t,
138  const unsigned int n)
139 {
140  std::advance (std_cxx11::get<0>(t), n);
141  std::advance (std_cxx11::get<1>(t), n);
142 }
143 
149 template <typename I1, typename I2, typename I3>
150 inline
151 void advance (std_cxx11::tuple<I1,I2,I3> &t,
152  const unsigned int n)
153 {
154  std::advance (std_cxx11::get<0>(t), n);
155  std::advance (std_cxx11::get<1>(t), n);
156  std::advance (std_cxx11::get<2>(t), n);
157 }
158 
164 template <typename I1, typename I2,
165  typename I3, typename I4>
166 inline
167 void advance (std_cxx11::tuple<I1,I2,I3, I4> &t,
168  const unsigned int n)
169 {
170  std::advance (std_cxx11::get<0>(t), n);
171  std::advance (std_cxx11::get<1>(t), n);
172  std::advance (std_cxx11::get<2>(t), n);
173  std::advance (std_cxx11::get<3>(t), n);
174 }
175 
176 
177 
183 template <typename I1, typename I2>
184 inline
185 void advance_by_one (std_cxx11::tuple<I1,I2> &t)
186 {
187  ++std_cxx11::get<0>(t);
188  ++std_cxx11::get<1>(t);
189 }
190 
196 template <typename I1, typename I2, typename I3>
197 inline
198 void advance_by_one (std_cxx11::tuple<I1,I2,I3> &t)
199 {
200  ++std_cxx11::get<0>(t);
201  ++std_cxx11::get<1>(t);
202  ++std_cxx11::get<2>(t);
203 }
204 
210 template <typename I1, typename I2,
211  typename I3, typename I4>
212 inline
213 void advance_by_one (std_cxx11::tuple<I1,I2,I3,I4> &t)
214 {
215  ++std_cxx11::get<0>(t);
216  ++std_cxx11::get<1>(t);
217  ++std_cxx11::get<2>(t);
218  ++std_cxx11::get<3>(t);
219 }
220 
221 
222 
228 template <typename Iterators>
229 inline
232  const std::size_t n)
233 {
235  ::advance (x.iterators, n);
236  return x;
237 }
238 
244 template <typename Iterators>
245 inline
248 {
250  return a;
251 }
252 
253 
260 template <typename Iterators>
261 inline
262 bool
265 {
266  return (std_cxx11::get<0>(a.iterators) !=
267  std_cxx11::get<0>(b.iterators));
268 }
269 
270 DEAL_II_NAMESPACE_CLOSE
271 
272 #endif
std::size_t operator-(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)
void advance_by_one(std_cxx11::tuple< I1, I2, I3 > &t)
#define Assert(cond, exc)
Definition: exceptions.h:294
SynchronousIterators(const Iterators &i)
void advance(std_cxx11::tuple< I1, I2, I3, I4 > &t, const unsigned int n)
void advance(std_cxx11::tuple< I1, I2, I3 > &t, const unsigned int n)
void advance_by_one(std_cxx11::tuple< I1, I2 > &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)
void advance(std_cxx11::tuple< I1, I2 > &t, const unsigned int n)
void advance_by_one(std_cxx11::tuple< I1, I2, I3, I4 > &t)