Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
iterator_range.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2014 - 2019 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_iterator_range_h
17 #define dealii_iterator_range_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/template_constraints.h>
23 
24 #include <iterator>
25 
26 
27 DEAL_II_NAMESPACE_OPEN
28 
29 
30 // Forward declarations
31 template <typename Iterator>
33 
34 
35 
127 template <typename Iterator>
129 {
130 public:
135 
136 
140  using iterator = Iterator;
141 
147  IteratorRange();
148 
156  IteratorRange(const iterator begin, const iterator end);
157 
162  begin();
163 
168  begin() const;
169 
175  end() const;
176 
182  end();
183 
184 private:
189  const IteratorOverIterators it_end;
190 };
191 
192 
193 
198 template <typename Iterator>
200 {
201 public:
206  using BaseIterator = Iterator;
207 
214  explicit IteratorOverIterators(const BaseIterator &iterator);
215 
220  const BaseIterator &operator*() const;
221 
226  const BaseIterator *operator->() const;
227 
233  operator++();
234 
241  operator++(int);
242 
249  bool
250  operator!=(const IteratorOverIterators &i_o_i) const;
251 
265  operator const BaseIterator &() const;
266 
272  using iterator_category = std::forward_iterator_tag;
273  using value_type = Iterator;
274  using difference_type = typename Iterator::difference_type;
275  using pointer = Iterator *;
276  using reference = Iterator &;
277 
278 private:
283 };
284 
285 
286 
293 template <typename BaseIterator>
295 make_iterator_range(const BaseIterator & begin,
296  const typename identity<BaseIterator>::type &end)
297 {
298  IteratorRange<BaseIterator> ir(begin, end);
299  return ir;
300 }
301 
302 
303 // ------------------- template member functions
304 
305 
306 template <typename Iterator>
308  const BaseIterator &iterator)
309  : element_of_iterator_collection(iterator)
310 {}
311 
312 
313 
314 template <typename Iterator>
315 inline const typename IteratorOverIterators<Iterator>::BaseIterator &
317 {
318  return element_of_iterator_collection;
319 }
320 
321 
322 
323 template <typename Iterator>
324 inline const typename IteratorOverIterators<Iterator>::BaseIterator *
326 {
327  return &element_of_iterator_collection;
328 }
329 
330 
331 
332 template <typename Iterator>
335 {
336  ++element_of_iterator_collection;
337  return *this;
338 }
339 
340 
341 
342 template <typename Iterator>
345 {
346  const IteratorOverIterators old_value = *this;
347  ++element_of_iterator_collection;
348  return *old_value;
349 }
350 
351 
352 
353 template <typename Iterator>
354 inline bool
357 {
358  return element_of_iterator_collection != i_o_i.element_of_iterator_collection;
359 }
360 
361 
362 
363 template <typename Iterator>
365 {
366  return element_of_iterator_collection;
367 }
368 
369 
370 
371 template <typename Iterator>
373  : it_begin()
374  , it_end()
375 {}
376 
377 
378 
379 template <typename Iterator>
381  const iterator e)
382  : it_begin(b)
383  , it_end(e)
384 {}
385 
386 
387 template <typename Iterator>
390 {
391  return it_begin;
392 }
393 
394 
395 template <typename Iterator>
398 {
399  return it_begin;
400 }
401 
402 
403 template <typename Iterator>
406 {
407  return it_end;
408 }
409 
410 
411 template <typename Iterator>
414 {
415  return it_end;
416 }
417 
418 
419 DEAL_II_NAMESPACE_CLOSE
420 
421 #endif
std::forward_iterator_tag iterator_category
IteratorOverIterators begin()
const BaseIterator & operator*() const
const IteratorOverIterators it_begin
Iterator iterator
IteratorOverIterators & operator++()
const BaseIterator * operator->() const
bool operator!=(const IteratorOverIterators &i_o_i) const
IteratorOverIterators(const BaseIterator &iterator)
BaseIterator element_of_iterator_collection
::IteratorOverIterators< Iterator > IteratorOverIterators
IteratorOverIterators end() const