Reference documentation for deal.II version 8.5.1
|
#include <deal.II/base/array_view.h>
Public Types | |
typedef ElementType | value_type |
Public Member Functions | |
ArrayView () | |
ArrayView (value_type *starting_element, const std::size_t n_elements) | |
ArrayView (const ArrayView< typename boost::remove_cv< value_type >::type > &view) | |
std::size_t | size () const |
value_type & | operator[] (const std::size_t i) const |
Private Attributes | |
value_type *const | starting_element |
const std::size_t | n_elements |
Friends | |
class | ArrayView< const ElementType > |
Related Functions | |
(Note that these are not member functions.) | |
template<typename ElementType > | |
ArrayView< ElementType > | make_array_view (std::vector< ElementType > &vector) |
template<typename ElementType > | |
ArrayView< const ElementType > | make_array_view (const std::vector< ElementType > &vector) |
template<typename ElementType > | |
ArrayView< ElementType > | make_array_view (std::vector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view) |
template<typename ElementType > | |
ArrayView< const ElementType > | make_array_view (const std::vector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view) |
template<typename ElementType > | |
ArrayView< ElementType > | make_array_view (Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row) |
template<typename ElementType > | |
ArrayView< const ElementType > | make_array_view (const Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row) |
template<typename ElementType > | |
ArrayView< ElementType > | make_array_view (Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row, const typename Table< 2, ElementType >::size_type starting_column, const std::size_t size_of_view) |
template<typename ElementType > | |
ArrayView< const ElementType > | make_array_view (const Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row, const typename Table< 2, ElementType >::size_type starting_column, const std::size_t size_of_view) |
A class that represents a window of memory locations of type ElementType
and presents it as if it was an array that can be accessed via an operator[]
. In essence, this class is nothing more than just a pointer to the first location and an integer that represents the length of the array in elements. The memory remains owned by whoever allocated it, as this class does not take over ownership.
The advantage of using this class is that you don't have to pass around pairs of pointers and that operator[]
checks for the validity of the index with which you subscript this array view.
This class can handle views to both non-constant and constant memory locations. If you want to represent a view of a constant array, then the template argument type of this class needs to be const
as well. The following code snippet gives an example:
In either case, accessing an element of a view does not change the ArrayView object itself, and consequently ArrayView::operator[] is a const
function. This corresponds to the notion that a view simply represents a, well, "view" of memory that is owned by someone else. Thus, accessing elements of the view changes the memory managed by some other object, but not the view itself, allowing us to make ArrayView::operator[] a const
member function. This is in contrast to, say, std::vector, which manages the memory it points to and changing an element of the std::vector therefore changes the std::vector object itself – consequently, the std::vector::operator[] is non-const
.
Definition at line 71 of file array_view.h.
typedef ElementType ArrayView< ElementType >::value_type |
A typedef that denotes the "value_type" of this container-like class, i.e., the type of the element it "stores" or points to.
Definition at line 78 of file array_view.h.
Default constructor. Creates an invalid view that does not point to anything at all.
Definition at line 158 of file array_view.h.
|
inline |
Constructor.
[in] | starting_element | A pointer to the first element of the array this object should represent. |
[in] | n_elements | The length (in elements) of the chunk of memory this object should represent. |
Definition at line 168 of file array_view.h.
|
inline |
Copy constructor from array views that point to non-const
elements. If the current object will point to non-const
elements, then this is a straight forward copy constructor. On the other hand, if the current type's ElementType
template argument is a const
qualified type, then the current constructor is a conversion constructor that converts a non-const
view to a const
view, akin to converting a non-const
pointer to a const
pointer.
Definition at line 179 of file array_view.h.
|
inline |
Return the size (in elements) of the view of memory this object represents.
Definition at line 190 of file array_view.h.
|
inline |
Return a reference to the \(i\)th element of the range represented by the current object.
This function is marked as const
because it does not change the view object. It may however return a reference to a non-const
memory location depending on whether the template type of the class is const
or not.
Definition at line 199 of file array_view.h.
|
related |
Create a view to an entire std::vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.
This function is used for non-const
references to objects of vector type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.
[in] | vector | The vector for which we want to have an array view object. The array view corresponds to the entire vector. |
Definition at line 224 of file array_view.h.
|
related |
Create a view to an entire std::vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.
This function is used for const
references to objects of vector type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const
objects.
[in] | vector | The vector for which we want to have an array view object. The array view corresponds to the entire vector. |
Definition at line 248 of file array_view.h.
|
related |
Create a view to a part of a std::vector object. This is equivalent to initializing the ArrayView object with a pointer to the starting_index-
th element and the size_of_view
as the length of the view.
This function is used for non-const
references to objects of vector type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.
[in] | vector | The vector for which we want to have an array view object. |
[in] | starting_index | The index of the first element of the vector that will be part of this view. |
[in] | size_of_view |
starting_index + size_of_view <= vector.size()
Definition at line 277 of file array_view.h.
|
related |
Create a view to a part of a std::vector object. This is equivalent to initializing the ArrayView object with a pointer to the starting_index-
th element and the size_of_view
as the length of the view.
This function is used for const
references to objects of vector type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const
objects.
[in] | vector | The vector for which we want to have an array view object. |
[in] | starting_index | The index of the first element of the vector that will be part of this view. |
[in] | size_of_view |
starting_index + size_of_view <= vector.size()
Definition at line 312 of file array_view.h.
|
related |
Create a view to an entire row of a Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given row, and the length of the row as the length of the view.
This function is used for non-const
references to objects of Table type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.
[in] | table | The Table for which we want to have an array view object. The array view corresponds to an entire row. |
[in] | row | The index of the row into the table to which this view should correspond. |
Definition at line 344 of file array_view.h.
|
related |
Create a view to an entire row of a Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given row, and the length of the row as the length of the view.
This function is used for const
references to objects of Table type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const
objects.
[in] | table | The Table for which we want to have an array view object. The array view corresponds to an entire row. |
[in] | row | The index of the row into the table to which this view should correspond. |
Definition at line 372 of file array_view.h.
|
related |
Create a view to (a part of) a row of a Table<2> object.
This function is used for non-const
references to objects of Table type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.
[in] | table | The Table for which we want to have an array view object. The array view corresponds to an entire row. |
[in] | row | The index of the row into the table to which this view should correspond. |
[in] | starting_column | The index of the column into the given row of the table that corresponds to the first element of this view. |
[in] | size_of_view | The number of elements this view should have. This corresponds to the number of columns in the current row to which the view should correspond. |
Definition at line 403 of file array_view.h.
|
related |
Create a view to (a part of) a row of a Table<2> object.
This function is used for const
references to objects of Table type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const
objects.
[in] | table | The Table for which we want to have an array view object. The array view corresponds to an entire row. |
[in] | row | The index of the row into the table to which this view should correspond. |
[in] | starting_column | The index of the column into the given row of the table that corresponds to the first element of this view. |
[in] | size_of_view | The number of elements this view should have. This corresponds to the number of columns in the current row to which the view should correspond. |
Definition at line 441 of file array_view.h.
|
private |
A pointer to the first element of the range of locations in memory that this object represents.
Definition at line 141 of file array_view.h.
|
private |
The length of the array this object represents.
Definition at line 146 of file array_view.h.