Regina 7.3 Calculation Engine
|
A lightweight object that can be used for random access to all elements of a given multi-dimensional table. More...
#include <utilities/tableview.h>
Classes | |
class | iterator |
The iterator type for this table view. More... | |
Public Types | |
using | Subview = typename detail::ConstArrayOf< Element, dim... >::view |
The type returned by the square bracket operator. More... | |
using | Subarray = typename detail::ConstArrayOf< Element, dim... >::type |
The type of a slice of the underlying C-style array, when the first array index is fixed. More... | |
using | Array = typename detail::ConstArrayOf< Element, dim1, dim... >::type |
The type of the underlying C-style array, with all compile-time constant dimensions specified. More... | |
using | size_type = size_t |
The native integer type used for array indexing. More... | |
using | value_type = Element |
The type of element that is stored in this array. More... | |
using | reference = const Element & |
A reference to a single array element. More... | |
using | const_reference = const Element & |
A reference to a single array element. More... | |
using | const_iterator = iterator |
The iterator type for this table view. More... | |
Public Member Functions | |
constexpr | TableView (Subarray *array) |
Returns a view for the given C-style array. More... | |
constexpr | TableView (const TableView &)=default |
Creates a new copy of the given table view. More... | |
TableView & | operator= (const TableView &)=default |
Sets this to be a copy of the given table view. More... | |
constexpr std::array< size_t, dimension > | size () const |
Returns the size of this array, across all of the array dimensions. More... | |
constexpr Subview | operator[] (size_t index) const |
Returns the requested sub-array of a multi-dimensional array, or the requested element of a one-dimensional array. More... | |
const_iterator | begin () const |
Returns a C++ iterator pointing to the first sub-array (for a multi-dimensional array), or the first element (for a one-dimensional array). More... | |
const_iterator | end () const |
Returns a C++ iterator pointing beyond the last sub-array (for a multi-dimensional array), or the last element (for a one-dimensional array). More... | |
auto | __iter__ () const |
Returns a Python iterator over all sub-arrays (for a multi-dimensional array), or all elements (for a one-dimensional array). More... | |
constexpr bool | operator== (const TableView &other) const |
Determines whether this and the given table view are accessing the same underlying C-style array. More... | |
constexpr bool | operator!= (const TableView &other) const |
Determines whether this and the given table view are accessing different underlying C-style arrays. More... | |
Static Public Attributes | |
static constexpr int | dimension = 1 + sizeof...(dim) |
The dimension of the underlying C-style array. More... | |
A lightweight object that can be used for random access to all elements of a given multi-dimensional table.
This access is read-only, in the sense that both the table itself and the table elements are read-only. (Of course, if the table elements are non-const pointers then this means that the pointers cannot be reassigned to point to different objects, but the objects they point to can still be modified.)
This class is in a sense a multi-dimensional analogue to TableView (though it does also support one-dimensional tables).
Where this class differs from ListView is:
Element[a][b]...[z]
, where the array dimensions are compile-time constants. In contrast, ListView can also work with rich C++ container classes and variable-sized C-style arrays.TableView comes with deduction guides for tables of dimension ≤ 3. This means that you can simply create a TableView using the syntax TableView(array)
, where array is the underlying C-style array, without having to specify any TableView template arguments.
TableView objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.
Element | the type of element stored in the C-style array. This should not be a const type; the const modifier will be added automatically where necessary through the class interface. |
dim | the dimensions of the C-style array. There must always be at least one dimension supplied. |
using regina::TableView< Element, dim1, dim >::Array = typename detail::ConstArrayOf<Element, dim1, dim...>:: type |
The type of the underlying C-style array, with all compile-time constant dimensions specified.
using regina::TableView< Element, dim1, dim >::const_iterator = iterator |
The iterator type for this table view.
Both iterator and const_iterator are the same type, since TableView only offers read-only access to the underlying data. See the TableView::iterator class for further details.
using regina::TableView< Element, dim1, dim >::const_reference = const Element& |
A reference to a single array element.
Both reference and const_reference are the same, since this class only offers read-only access to the underlying array.
using regina::TableView< Element, dim1, dim >::reference = const Element& |
A reference to a single array element.
Both reference and const_reference are the same, since this class only offers read-only access to the underlying array.
using regina::TableView< Element, dim1, dim >::size_type = size_t |
The native integer type used for array indexing.
using regina::TableView< Element, dim1, dim >::Subarray = typename detail::ConstArrayOf<Element, dim...>::type |
The type of a slice of the underlying C-style array, when the first array index is fixed.
If this array is one-dimensional, then this is simply const Element
.
using regina::TableView< Element, dim1, dim >::Subview = typename detail::ConstArrayOf<Element, dim...>::view |
The type returned by the square bracket operator.
For an array with multiple dimensions, this is a TableView of smaller dimension. For a one-dimensional array, this is a const reference to Element.
See the square bracket operator for further details.
using regina::TableView< Element, dim1, dim >::value_type = Element |
The type of element that is stored in this array.
|
inlineconstexpr |
Returns a view for the given C-style array.
array | the pointer to the C-style array. |
|
constexprdefault |
Creates a new copy of the given table view.
auto regina::TableView< Element, dim1, dim >::__iter__ | ( | ) | const |
Returns a Python iterator over all sub-arrays (for a multi-dimensional array), or all elements (for a one-dimensional array).
For a TableView t, this iterator will run through the subarrays/elements t[0]
, t[1]
, ..., in order from first to last.
In particular, for a multi-dimensional array, a single iterator will not run through the individual array elements; for this you will need t.dimension
nested iterations.
for
loop.
|
inline |
Returns a C++ iterator pointing to the first sub-array (for a multi-dimensional array), or the first element (for a one-dimensional array).
For a TableView t, the iterator range from t.begin()
to t.end()
runs through the subarrays/elements t[0]
, t[1]
, ..., in order from first to last.
In particular, for a multi-dimensional array, a single iterator will not run through the individual array elements; for this you will need t.dimension
nested iterations.
|
inline |
Returns a C++ iterator pointing beyond the last sub-array (for a multi-dimensional array), or the last element (for a one-dimensional array).
For a TableView t, the iterator range from t.begin()
to t.end()
runs through the subarrays/elements t[0]
, t[1]
, ..., in order from first to last.
See begin() for further details.
|
inlineconstexpr |
Determines whether this and the given table view are accessing different underlying C-style arrays.
To be considered the same array, the two arrays must have the same location in memory (i.e., the pointers that define the C-style arrays must be equal). In particular, it is not enough for the two arrays just to have identical contents.
other | the table view to compare with this. |
true
if and only if this and the given table use different underlying C-style arrays.
|
default |
Sets this to be a copy of the given table view.
|
inlineconstexpr |
Determines whether this and the given table view are accessing the same underlying C-style array.
To be considered the same array, the two arrays must have the same location in memory (i.e., the pointers that define the C-style arrays must be equal). In particular, it is not enough for the two arrays just to have identical contents.
other | the table view to compare with this. |
true
if and only if this and the given table use the same underlying C-style array.
|
inlineconstexpr |
Returns the requested sub-array of a multi-dimensional array, or the requested element of a one-dimensional array.
If this array is one-dimensional then this operator simply returns the (index)th element, as a const reference.
If this array has more than one dimension then this operator returns a TableView of smaller dimension, by value, representing the slice of the overall table obtained when the first array index is set to the given value.
Typically this operator would just be used to access an individual element using the syntax array[index_1][index_2]...[index_dim]
, where dim is the dimension of this array.
index | indicates which element or sub-array to return; this must be between 0 and (dim1-1) inclusive. |
|
inlineconstexpr |
Returns the size of this array, across all of the array dimensions.
This returns a sequence (s_1, s_2, ..., s_dim), where dim is the dimension of this array, and where the kth array subscript ranges from 0 to (s_k-1) inclusive.
|
staticconstexpr |
The dimension of the underlying C-style array.
This is the number of subscripts required to access an individual array element.