Reference documentation for deal.II version 9.3.3
|
#include <deal.II/base/linear_index_iterator.h>
Public Types | |
using | iterator_category = std::random_access_iterator_tag |
using | value_type = AccessorType |
using | difference_type = std::ptrdiff_t |
using | reference = const value_type & |
using | pointer = const value_type * |
using | size_type = typename value_type::size_type |
Public Member Functions | |
DerivedIterator & | operator= (const DerivedIterator &it) |
DerivedIterator & | operator++ () |
DerivedIterator | operator++ (int) |
DerivedIterator & | operator-- () |
DerivedIterator | operator-- (int) |
DerivedIterator | operator+ (const difference_type n) const |
DerivedIterator | operator- (const difference_type n) const |
DerivedIterator & | operator+= (const difference_type n) |
DerivedIterator & | operator-= (const difference_type n) |
difference_type | operator- (const DerivedIterator &p) const |
reference | operator* () const |
pointer | operator-> () const |
bool | operator<= (const DerivedIterator &) const |
bool | operator>= (const DerivedIterator &) const |
bool | operator< (const DerivedIterator &) const |
bool | operator> (const DerivedIterator &) const |
Protected Member Functions | |
LinearIndexIterator ()=default | |
LinearIndexIterator (const AccessorType accessor) | |
Protected Attributes | |
AccessorType | accessor |
Friends | |
template<typename OtherIterator > | |
std::enable_if< std::is_convertible< OtherIterator, DerivedIterator >::value, bool >::type | operator== (const LinearIndexIterator &left, const OtherIterator &right) |
template<typename OtherIterator > | |
std::enable_if< std::is_convertible< OtherIterator, DerivedIterator >::value, bool >::type | operator!= (const LinearIndexIterator &left, const OtherIterator &right) |
Many classes in deal.II, such as FullMatrix, TransposeTable, and SparseMatrix, store their data in contiguous buffers (though the interpretation of what the elements of these buffers represent can, of course, be complex). For example, FullMatrix and TransposeTable store their data in row major and column major order respectively, whereas for SparseMatrix the mapping from buffer location to matrix entry \(\mathbf{A}(i, j)\) is more complicated. In any case, however, the contiguous arrangements of elements enables random access iteration.
LinearIndexIterator provides most of the functionality needed to write iterators for these classes. LinearIndexIterator is essentially a simplified version of boost::iterator_facade
that assumes AccessorType
provides certain members (documented below) that completely describe the state of the iterator. The intended use of this class is for containers to define their own accessor classes and then use the curiously recurring template pattern (CRTP) technique to define their iterators. For example, here is a container that uses LinearIndexIterator to define its own iterator classes:
DerivedIterator | As shown in the example above, concrete iterator classes should use this class with the CRTP technique: this provides the boiler-plate comparison and arithmetic operators for iterators. This is necessary for, e.g., LinearIndexIterator::operator++() to return the correct type. |
AccessorType | LinearIndexIterator assumes that the AccessorType template parameter has the following members which completely describe the current state of the iterator:
AccessorType should declare the relevant LinearIndexIterator instantiation to be a friend and define a size_type type. |
Definition at line 139 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::iterator_category = std::random_access_iterator_tag |
Iterator category.
Definition at line 145 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::value_type = AccessorType |
An alias for the type you get when you dereference an iterator of the current kind.
Definition at line 151 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::difference_type = std::ptrdiff_t |
Difference type.
Definition at line 156 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::reference = const value_type & |
Reference type.
Definition at line 161 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::pointer = const value_type * |
Pointer type.
Definition at line 166 of file linear_index_iterator.h.
using LinearIndexIterator< DerivedIterator, AccessorType >::size_type = typename value_type::size_type |
Size type used by the underlying container.
Definition at line 171 of file linear_index_iterator.h.
|
protecteddefault |
|
inlineprotected |
Constructor that copies an accessor.
Definition at line 502 of file linear_index_iterator.h.
|
inline |
Copy operator.
Definition at line 331 of file linear_index_iterator.h.
|
inline |
Prefix increment.
Definition at line 343 of file linear_index_iterator.h.
|
inline |
Postfix increment.
Definition at line 352 of file linear_index_iterator.h.
|
inline |
Prefix decrement.
Definition at line 363 of file linear_index_iterator.h.
|
inline |
Postfix decrement.
Definition at line 372 of file linear_index_iterator.h.
|
inline |
Return an iterator that is n
entries ahead of the current one.
Definition at line 383 of file linear_index_iterator.h.
|
inline |
Return an iterator that is n
entries behind the current one.
Definition at line 395 of file linear_index_iterator.h.
|
inline |
Increment the iterator position by n
.
Definition at line 407 of file linear_index_iterator.h.
|
inline |
Decrement the iterator position by n
.
Definition at line 418 of file linear_index_iterator.h.
|
inline |
Return the distance between the current iterator and the argument. The distance is given by how many times one has to apply operator++() to the current iterator to get the argument (for a positive return value), or operator--() (for a negative return value).
Definition at line 429 of file linear_index_iterator.h.
|
inline |
Dereferencing operator.
Definition at line 442 of file linear_index_iterator.h.
|
inline |
Dereferencing operator.
Definition at line 451 of file linear_index_iterator.h.
|
inline |
Comparison operator: uses the same ordering as operator<(), but also checks for equality.
This function is only valid if both iterators point into the same container.
Definition at line 459 of file linear_index_iterator.h.
|
inline |
Comparison operator: uses the same ordering as operator>(), but also checks for equality.
This function is only valid if both iterators point into the same container.
Definition at line 470 of file linear_index_iterator.h.
|
inline |
Comparison operator. Result is true if either the first row number is smaller or if the row numbers are equal and the first index is smaller.
This function is only valid if both iterators point into the same container.
Definition at line 479 of file linear_index_iterator.h.
|
inline |
Comparison operator. Works in the same way as operator<(), just the other way round.
Definition at line 493 of file linear_index_iterator.h.
|
friend |
Comparison operator. Returns true
if both iterators point to the same entry in the same container.
Definition at line 254 of file linear_index_iterator.h.
|
friend |
Opposite of operator==().
Definition at line 267 of file linear_index_iterator.h.
|
protected |
Store an object of the accessor class.
Definition at line 324 of file linear_index_iterator.h.