/usr/include/deal.II/base/synchronous_iterator.h is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | //---------------------------------------------------------------------------
// $Id: synchronous_iterator.h 19791 2009-10-09 23:39:30Z bangerth $
// Version: $Name$
//
// Copyright (C) 2008, 2009 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__synchronous_iterator_h
#define __deal2__synchronous_iterator_h
#include <base/config.h>
#include <base/exceptions.h>
#include <base/std_cxx1x/tuple.h>
#include <iterator>
DEAL_II_NAMESPACE_OPEN
/**
* A class that represents a set of
* iterators each of which are
* incremented by one at the same
* time. This is typically used in calls
* like <code>std::transform(a.begin(),
* a.end(), b.begin(), functor);</code>
* where we have synchronous iterators
* marching through the containers
* <code>a,b</code>. If an object of this
* type represents the end of a range,
* only the first element is considered
* (we only have <code>a.end()</code>,
* not <code>b.end()</code>)
*
* The template argument of the current
* class shall be of type
* <code>std_cxx1x::tuple</code> with
* arguments equal to the iterator types.
*
* This type, and the helper functions
* associated with it, are used as the
* Value concept for the blocked_range
* type of the Threading Building Blocks.
*
* @author Wolfgang Bangerth, 2008
*/
template <typename Iterators>
struct SynchronousIterators
{
/**
* Constructor.
*/
SynchronousIterators (const Iterators &i);
/**
* Copy constructor.
*/
SynchronousIterators (const SynchronousIterators &i);
/**
* Storage for the iterators
* represented by the current class.
*/
Iterators iterators;
};
template <typename Iterators>
inline
SynchronousIterators<Iterators>::
SynchronousIterators (const Iterators &i)
:
iterators (i)
{}
template <typename Iterators>
inline
SynchronousIterators<Iterators>::
SynchronousIterators (const SynchronousIterators &i)
:
iterators (i.iterators)
{}
/**
* Return whether the first element of
* the first argument is less than the
* first element of the second
* argument. Since the objects compared
* march forward all elements at the same
* time, comparing the first element is
* sufficient.
*/
template <typename Iterators>
inline
bool
operator< (const SynchronousIterators<Iterators> &a,
const SynchronousIterators<Iterators> &b)
{
return std_cxx1x::get<0>(a.iterators) < std_cxx1x::get<0>(b.iterators);
}
/**
* Return the distance between the first
* and the second argument. Since the
* objects compared march forward all
* elements at the same time,
* differencing the first element is
* sufficient.
*/
template <typename Iterators>
inline
std::size_t
operator- (const SynchronousIterators<Iterators> &a,
const SynchronousIterators<Iterators> &b)
{
Assert (std::distance (std_cxx1x::get<0>(b.iterators),
std_cxx1x::get<0>(a.iterators)) >= 0,
ExcInternalError());
return std::distance (std_cxx1x::get<0>(b.iterators),
std_cxx1x::get<0>(a.iterators));
}
/**
* Advance a tuple of iterators by $n$.
*/
template <typename I1, typename I2>
inline
void advance (std_cxx1x::tuple<I1,I2> &t,
const unsigned int n)
{
std::advance (std_cxx1x::get<0>(t), n);
std::advance (std_cxx1x::get<1>(t), n);
}
/**
* Advance a tuple of iterators by $n$.
*/
template <typename I1, typename I2, typename I3>
inline
void advance (std_cxx1x::tuple<I1,I2,I3> &t,
const unsigned int n)
{
std::advance (std_cxx1x::get<0>(t), n);
std::advance (std_cxx1x::get<1>(t), n);
std::advance (std_cxx1x::get<2>(t), n);
}
/**
* Advance a tuple of iterators by $n$.
*/
template <typename I1, typename I2,
typename I3, typename I4>
inline
void advance (std_cxx1x::tuple<I1,I2,I3, I4> &t,
const unsigned int n)
{
std::advance (std_cxx1x::get<0>(t), n);
std::advance (std_cxx1x::get<1>(t), n);
std::advance (std_cxx1x::get<2>(t), n);
std::advance (std_cxx1x::get<3>(t), n);
}
/**
* Advance a tuple of iterators by 1.
*/
template <typename I1, typename I2>
inline
void advance_by_one (std_cxx1x::tuple<I1,I2> &t)
{
++std_cxx1x::get<0>(t);
++std_cxx1x::get<1>(t);
}
/**
* Advance a tuple of iterators by 1.
*/
template <typename I1, typename I2, typename I3>
inline
void advance_by_one (std_cxx1x::tuple<I1,I2,I3> &t)
{
++std_cxx1x::get<0>(t);
++std_cxx1x::get<1>(t);
++std_cxx1x::get<2>(t);
}
/**
* Advance a tuple of iterators by 1.
*/
template <typename I1, typename I2,
typename I3, typename I4>
inline
void advance_by_one (std_cxx1x::tuple<I1,I2,I3,I4> &t)
{
++std_cxx1x::get<0>(t);
++std_cxx1x::get<1>(t);
++std_cxx1x::get<2>(t);
++std_cxx1x::get<3>(t);
}
/**
* Advance the elements of this iterator
* by $n$.
*/
template <typename Iterators>
inline
SynchronousIterators<Iterators>
operator + (const SynchronousIterators<Iterators> &a,
const std::size_t n)
{
SynchronousIterators<Iterators> x (a);
dealii::advance (x.iterators, n);
return x;
}
/**
* Advance the elements of this iterator
* by 1.
*/
template <typename Iterators>
inline
SynchronousIterators<Iterators>
operator ++ (SynchronousIterators<Iterators> &a)
{
dealii::advance_by_one (a.iterators);
return a;
}
/**
* Compare synch iterators for
* inequality. Since they march in synch,
* comparing only the first element is
* sufficient.
*/
template <typename Iterators>
inline
bool
operator != (const SynchronousIterators<Iterators> &a,
const SynchronousIterators<Iterators> &b)
{
return (std_cxx1x::get<0>(a.iterators) !=
std_cxx1x::get<0>(b.iterators));
}
DEAL_II_NAMESPACE_CLOSE
#endif
|