deal.II version GIT relicensing-2238-gc05b561aad 2024-12-10 20:50:00+00:00
|
#include <deal.II/lac/block_vector_base.h>
Public Types | |
using | size_type = types::global_dof_index |
using | value_type = std::conditional_t< Constness, const typename BlockVectorType::value_type, typename BlockVectorType::value_type > |
using | iterator_category = std::random_access_iterator_tag |
using | difference_type = std::ptrdiff_t |
using | reference = typename BlockVectorType::reference |
using | pointer = value_type * |
using | dereference_type = std::conditional_t< Constness, value_type, typename BlockVectorType::BlockType::reference > |
using | BlockVector = std::conditional_t< Constness, const BlockVectorType, BlockVectorType > |
Public Member Functions | |
Iterator (BlockVector &parent, const size_type global_index) | |
Iterator (const Iterator< BlockVectorType, !Constness > &c) | |
Iterator (const Iterator &c) | |
Iterator & | operator= (const Iterator &c) |
dereference_type | operator* () const |
dereference_type | operator[] (const difference_type d) const |
Iterator & | operator++ () |
Iterator | operator++ (int) |
Iterator & | operator-- () |
Iterator | operator-- (int) |
template<bool OtherConstness> | |
bool | operator== (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
bool | operator!= (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
bool | operator< (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
bool | operator<= (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
bool | operator> (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
bool | operator>= (const Iterator< BlockVectorType, OtherConstness > &i) const |
template<bool OtherConstness> | |
difference_type | operator- (const Iterator< BlockVectorType, OtherConstness > &i) const |
Iterator | operator+ (const difference_type &d) const |
Iterator | operator- (const difference_type &d) const |
Iterator & | operator+= (const difference_type &d) |
Iterator & | operator-= (const difference_type &d) |
Static Public Member Functions | |
static ::ExceptionBase & | ExcPointerToDifferentVectors () |
Private Member Functions | |
Iterator (BlockVector &parent, const size_type global_index, const size_type current_block, const size_type index_within_block, const size_type next_break_forward, const size_type next_break_backward) | |
void | move_forward () |
void | move_backward () |
Private Attributes | |
BlockVector * | parent |
size_type | global_index |
unsigned int | current_block |
size_type | index_within_block |
size_type | next_break_forward |
size_type | next_break_backward |
Friends | |
template<typename , bool > | |
class | Iterator |
General random-access iterator class for block vectors. Since we do not want to have two classes for non-const iterator and const_iterator, we take a second template argument which denotes whether the vector we point into is a constant object or not. The first template argument is always the number type of the block vector in use.
This class satisfies all requirements of random access iterators defined in the C++ standard. Operations on these iterators are constant in the number of elements in the block vector. However, they are sometimes linear in the number of blocks in the vector, but since that does rarely change dynamically within an application, this is a constant and we again have that the iterator satisfies the requirements of a random access iterator.
Definition at line 120 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::size_type = types::global_dof_index |
Declare the type for container size.
Definition at line 126 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::value_type = std::conditional_t<Constness, const typename BlockVectorType::value_type, typename BlockVectorType::value_type> |
Type of the number this iterator points to. Depending on the value of the second template parameter, this is either a constant or non-const number.
Definition at line 133 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::iterator_category = std::random_access_iterator_tag |
Declare some aliases that are standard for iterators and are used by algorithms to enquire about the specifics of the iterators they work on. (Example: std::next()
, which needs to know about a local type named difference_type
.)
As for the iterator_category, C++20 has a more specialized contiguous_iterator_tag, but the elements of block vectors are not stored in a contiguous manner. They can be accessed in a random access order, though, with O(1) effort as long as we assume that the number of blocks of a vector is a constant (even though the size of the vector is not).
Definition at line 151 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::difference_type = std::ptrdiff_t |
Definition at line 152 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::reference = typename BlockVectorType::reference |
Definition at line 153 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::pointer = value_type * |
Definition at line 154 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::dereference_type = std::conditional_t<Constness, value_type, typename BlockVectorType::BlockType::reference> |
Definition at line 156 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::BlockVector = std::conditional_t<Constness, const BlockVectorType, BlockVectorType> |
Typedef the type of the block vector (which differs in constness, depending on the second template parameter).
Definition at line 165 of file block_vector_base.h.
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | BlockVector & | parent, |
const size_type | global_index | ||
) |
Construct an iterator from a vector to which we point and the global index of the element pointed to.
Depending on the value of the Constness
template argument of this class, the first argument of this constructor is either is a const or non-const reference.
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | const Iterator< BlockVectorType, !Constness > & | c | ) |
Copy constructor from an iterator of different constness.
static_assert
). internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | const Iterator< BlockVectorType, Constness > & | c | ) |
Copy constructor from an iterator with the same constness.
|
private |
Constructor used internally in this class. The arguments match exactly the values of the respective member variables.
Iterator & internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator= | ( | const Iterator< BlockVectorType, Constness > & | c | ) |
Copy operator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator* | ( | ) | const |
Dereferencing operator. If the template argument Constness
is true
, then no writing to the result is possible, making this a const_iterator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator[] | ( | const difference_type | d | ) | const |
Random access operator, grant access to arbitrary elements relative to the one presently pointed to.
Iterator & internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator++ | ( | ) |
Prefix increment operator. This operator advances the iterator to the next element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator++ | ( | int | ) |
Postfix increment operator. This operator advances the iterator to the next element and returns a copy of the old value of this iterator.
Iterator & internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-- | ( | ) |
Prefix decrement operator. This operator retracts the iterator to the previous element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-- | ( | int | ) |
Postfix decrement operator. This operator retracts the iterator to the previous element and returns a copy of the old value of this iterator.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator== | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Compare for equality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator!= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Compare for inequality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator< | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Check whether this iterators points to an element previous to the one pointed to by the given argument. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator<= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator> | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator>= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
difference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator- | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Return the distance between the two iterators, in elements.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator+ | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements in front of the present one.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator- | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements behind the present one.
Iterator & internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator+= | ( | const difference_type & | d | ) |
Move the iterator d
elements forward at once, and return the result.
Iterator & internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-= | ( | const difference_type & | d | ) |
Move the iterator d
elements backward at once, and return the result.
|
private |
Move forward one element.
|
private |
Move backward one element.
|
friend |
Definition at line 396 of file block_vector_base.h.
|
private |
Pointer to the block vector object to which this iterator points. Depending on the value of the Constness
template argument of this class, this is a const
or non-const
pointer.
Definition at line 359 of file block_vector_base.h.
|
private |
Global index of the element to which we presently point.
Definition at line 364 of file block_vector_base.h.
|
private |
Current block and index within this block of the element presently pointed to.
Definition at line 370 of file block_vector_base.h.
|
private |
Definition at line 371 of file block_vector_base.h.
|
private |
Indices of the global element address at which we have to move on to another block when moving forward and backward. These indices are kept as a cache since this is much more efficient than always asking the parent object.
Definition at line 379 of file block_vector_base.h.
|
private |
Definition at line 380 of file block_vector_base.h.