A specialisation of ListView for working with lists stored in a C-style array whose size is fixed at compile-time.
More...
#include <utilities/listview.h>
template<typename Element, size_t n>
class regina::ListView< Element[n]>
A specialisation of ListView for working with lists stored in a C-style array whose size is fixed at compile-time.
See the generic ListView class documentation for full details on how this class works and how to use it.
- Python
- As with the generic ListView template classes, Python will automatically translate any C++ ListView object into an internal lightweight class that supports both iteration and indexing at the Python level.
- Template Parameters
-
Element | the type of element stored in the C-style array. This should not be a const type; the const modifier will added automatically where necessary through the class interface. |
◆ const_iterator
template<typename Element , size_t n>
The iterator type for this list view.
Both iterator and const_iterator are the same, since this class only offers read-only access to the underlying list.
◆ const_reference
template<typename Element , size_t n>
A reference to a list element.
Both reference and const_reference are the same, since this class only offers read-only access to the underlying list.
◆ iterator
template<typename Element , size_t n>
The iterator type for this list view.
Both iterator and const_iterator are the same, since this class only offers read-only access to the underlying list.
◆ reference
template<typename Element , size_t n>
A reference to a list element.
Both reference and const_reference are the same, since this class only offers read-only access to the underlying list.
◆ size_type
template<typename Element , size_t n>
The type used for indexing into this list.
◆ value_type
template<typename Element , size_t n>
The type of element that is stored in this list.
◆ ListView() [1/2]
template<class Element , size_t n>
Returns a view for the given C-style array.
Internally, this object will store a pointer to the array, which means the array needs to exist for at least as long as this object.
- Python
- Not present.
- Parameters
-
array | the pointer to the C-style array. |
◆ ListView() [2/2]
template<typename Element , size_t n>
Creates a new copy of the given list view.
◆ __iter__()
template<typename Element , size_t n>
Returns a Python iterator over the elements of this list.
- C++
- Not present. For C++ users, ListView provides the usual begin() and end() functions instead. In particular, you can iterate over the elements of this list in the usual way using a range-based
for
loop.
- Returns
- an iterator over the elements of this list.
◆ back()
template<class Element , size_t n>
Returns the last element of this list.
- Precondition
- This list is not empty.
- Returns
- the last element in this list.
◆ begin()
template<class Element , size_t n>
Returns a C++ iterator pointing to the first element of this list.
- Python
- Not present. For Python users, ListView implements the Python iterable interface. You can iterate over the elements of this list in the same way that you would iterate over any native Python container.
- Returns
- an iterator at the beginning of this list.
◆ empty()
template<class Element , size_t n>
Determines if this list is empty.
- Returns
true
if and only if this list is empty.
◆ end()
template<class Element , size_t n>
Returns a C++ iterator pointing beyond the last element of this list.
- Python
- Not present. For Python users, ListView implements the Python iterable interface. You can iterate over the elements of this list in the same way that you would iterate over any native Python container.
- Returns
- an iterator beyond the end of this list.
◆ front()
template<class Element , size_t n>
Returns the first element of this list.
- Precondition
- This list is not empty.
- Returns
- the first element in this list.
◆ operator!=()
template<class Element , size_t n>
Determines whether this and the given list 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.
- Parameters
-
other | the list view to compare with this. |
- Returns
true
if and only if this and the given list use different underlying arrays.
◆ operator=()
template<typename Element , size_t n>
Sets this to be a copy of the given list view.
- Returns
- a reference to this list view.
◆ operator==()
template<class Element , size_t n>
Determines whether this and the given list 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.
- Parameters
-
other | the list view to compare with this. |
- Returns
true
if and only if this and the given list use the same underlying array.
◆ operator[]()
template<class Element , size_t n>
Returns the requested element of this list.
- Parameters
-
index | indicates which element to return; this must be between 0 and size()-1 inclusive. |
- Returns
- the (index)th element in this list.
◆ size()
template<class Element , size_t n>
Returns the number of elements in this list.
- Python
- This is also used to implement the Python special method len().
- Returns
- the number of elements.
The documentation for this class was generated from the following file: