Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
synchronous_iterator.h
1 // ---------------------------------------------------------------------
2 // @f$Id: synchronous_iterator.h 31932 2013-12-08 02:15:54Z heister @f$
3 //
4 // Copyright (C) 2008 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__synchronous_iterator_h
18 #define __deal2__synchronous_iterator_h
19 
20 
21 #include <deal.II/base/config.h>
23 
24 #include <deal.II/base/std_cxx1x/tuple.h>
25 
26 #include <iterator>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
57 template <typename Iterators>
59 {
63  SynchronousIterators (const Iterators &i);
64 
69 
74  Iterators iterators;
75 };
76 
77 
78 
79 template <typename Iterators>
80 inline
82 SynchronousIterators (const Iterators &i)
83  :
84  iterators (i)
85 {}
86 
87 
88 template <typename Iterators>
89 inline
92  :
93  iterators (i.iterators)
94 {}
95 
96 
97 
107 template <typename Iterators>
108 inline
109 bool
110 operator< (const SynchronousIterators<Iterators> &a,
112 {
113  return std_cxx1x::get<0>(a.iterators) < std_cxx1x::get<0>(b.iterators);
114 }
115 
116 
117 
126 template <typename Iterators>
127 inline
128 std::size_t
131 {
132  Assert (std::distance (std_cxx1x::get<0>(b.iterators),
133  std_cxx1x::get<0>(a.iterators)) >= 0,
134  ExcInternalError());
135  return std::distance (std_cxx1x::get<0>(b.iterators),
136  std_cxx1x::get<0>(a.iterators));
137 }
138 
139 
143 template <typename I1, typename I2>
144 inline
145 void advance (std_cxx1x::tuple<I1,I2> &t,
146  const unsigned int n)
147 {
148  std::advance (std_cxx1x::get<0>(t), n);
149  std::advance (std_cxx1x::get<1>(t), n);
150 }
151 
155 template <typename I1, typename I2, typename I3>
156 inline
157 void advance (std_cxx1x::tuple<I1,I2,I3> &t,
158  const unsigned int n)
159 {
160  std::advance (std_cxx1x::get<0>(t), n);
161  std::advance (std_cxx1x::get<1>(t), n);
162  std::advance (std_cxx1x::get<2>(t), n);
163 }
164 
168 template <typename I1, typename I2,
169  typename I3, typename I4>
170 inline
171 void advance (std_cxx1x::tuple<I1,I2,I3, I4> &t,
172  const unsigned int n)
173 {
174  std::advance (std_cxx1x::get<0>(t), n);
175  std::advance (std_cxx1x::get<1>(t), n);
176  std::advance (std_cxx1x::get<2>(t), n);
177  std::advance (std_cxx1x::get<3>(t), n);
178 }
179 
180 
181 
185 template <typename I1, typename I2>
186 inline
187 void advance_by_one (std_cxx1x::tuple<I1,I2> &t)
188 {
189  ++std_cxx1x::get<0>(t);
190  ++std_cxx1x::get<1>(t);
191 }
192 
196 template <typename I1, typename I2, typename I3>
197 inline
198 void advance_by_one (std_cxx1x::tuple<I1,I2,I3> &t)
199 {
200  ++std_cxx1x::get<0>(t);
201  ++std_cxx1x::get<1>(t);
202  ++std_cxx1x::get<2>(t);
203 }
204 
208 template <typename I1, typename I2,
209  typename I3, typename I4>
210 inline
211 void advance_by_one (std_cxx1x::tuple<I1,I2,I3,I4> &t)
212 {
213  ++std_cxx1x::get<0>(t);
214  ++std_cxx1x::get<1>(t);
215  ++std_cxx1x::get<2>(t);
216  ++std_cxx1x::get<3>(t);
217 }
218 
219 
220 
225 template <typename Iterators>
226 inline
229  const std::size_t n)
230 {
232  ::advance (x.iterators, n);
233  return x;
234 }
235 
240 template <typename Iterators>
241 inline
243 operator ++ (SynchronousIterators<Iterators> &a)
244 {
245  ::advance_by_one (a.iterators);
246  return a;
247 }
248 
249 
256 template <typename Iterators>
257 inline
258 bool
259 operator != (const SynchronousIterators<Iterators> &a,
261 {
262  return (std_cxx1x::get<0>(a.iterators) !=
263  std_cxx1x::get<0>(b.iterators));
264 }
265 
266 DEAL_II_NAMESPACE_CLOSE
267 
268 #endif
VectorizedArray< Number > operator+(const VectorizedArray< Number > &u, const VectorizedArray< Number > &v)
VectorizedArray< Number > operator-(const VectorizedArray< Number > &u, const VectorizedArray< Number > &v)
#define Assert(cond, exc)
Definition: exceptions.h:299
SynchronousIterators(const Iterators &i)
::ExceptionBase & ExcInternalError()