Regina 7.3 Calculation Engine
Public Types | Public Member Functions | Friends | List of all members
regina::TableView< Element, dim1, dim >::iterator Class Reference

The iterator type for this table view. More...

#include <utilities/tableview.h>

Public Types

using value_type = std::remove_reference_t< Subview >
 Indicates what type the iterator points to. More...
 
using iterator_category = std::input_iterator_tag
 Declares this to be an input iterator type. More...
 
using difference_type = ptrdiff_t
 The type obtained by subtracting iterators. More...
 
using pointer = const value_type *
 A pointer to value_type. More...
 
using reference = Subview
 The type returned by the dereference operator, which could be by value (for a multi-dimensional table) or by reference (for a one-dimensional table). More...
 

Public Member Functions

 iterator ()=default
 Creates a new uninitialised iterator. More...
 
 iterator (const iterator &)=default
 Creates a copy of the given iterator. More...
 
iteratoroperator= (const iterator &)=default
 Makes this a copy of the given iterator. More...
 
bool operator== (const iterator &rhs) const
 Compares this with the given iterator for equality. More...
 
bool operator!= (const iterator &rhs) const
 Compares this with the given iterator for inequality. More...
 
iteratoroperator++ ()
 The preincrement operator. More...
 
iterator operator++ (int)
 The postincrement operator. More...
 
iteratoroperator-- ()
 The predecrement operator. More...
 
iterator operator-- (int)
 The postdecrement operator. More...
 
Subview operator* () const
 Returns the subarray or element of the underlying table that this iterator is currently pointing to. More...
 

Friends

class TableView
 

Detailed Description

template<typename Element, size_t dim1, size_t... dim>
class regina::TableView< Element, dim1, dim >::iterator

The iterator type for this table view.

For a TableView t, an iterator of this type runs through the subarrays/elements t[0], t[1], ..., in order from first to last. See TableView::begin() for further details.

This iterator is, in spirit, a bidirectional multipass iterator. However, we declare it using std::input_iterator_tag here because it does not necessarily return by reference (a requirement of forward and bidirectional iterators in the C++ standard library). In particular:

Both iterator and const_iterator are the same type, since TableView only offers read-only access to the underlying data.

Python
Not present. TableView is an iterable type, but its iter() function returns an object of a different (hidden) iterator class.

Member Typedef Documentation

◆ difference_type

template<typename Element , size_t dim1, size_t... dim>
using regina::TableView< Element, dim1, dim >::iterator::difference_type = ptrdiff_t

The type obtained by subtracting iterators.

◆ iterator_category

template<typename Element , size_t dim1, size_t... dim>
using regina::TableView< Element, dim1, dim >::iterator::iterator_category = std::input_iterator_tag

Declares this to be an input iterator type.

◆ pointer

template<typename Element , size_t dim1, size_t... dim>
using regina::TableView< Element, dim1, dim >::iterator::pointer = const value_type*

A pointer to value_type.

◆ reference

template<typename Element , size_t dim1, size_t... dim>
using regina::TableView< Element, dim1, dim >::iterator::reference = Subview

The type returned by the dereference operator, which could be by value (for a multi-dimensional table) or by reference (for a one-dimensional table).

See the iterator class notes for details.

◆ value_type

template<typename Element , size_t dim1, size_t... dim>
using regina::TableView< Element, dim1, dim >::iterator::value_type = std::remove_reference_t<Subview>

Indicates what type the iterator points to.

Constructor & Destructor Documentation

◆ iterator() [1/2]

template<typename Element , size_t dim1, size_t... dim>
regina::TableView< Element, dim1, dim >::iterator::iterator ( )
default

Creates a new uninitialised iterator.

◆ iterator() [2/2]

template<typename Element , size_t dim1, size_t... dim>
regina::TableView< Element, dim1, dim >::iterator::iterator ( const iterator )
default

Creates a copy of the given iterator.

Member Function Documentation

◆ operator!=()

template<typename Element , size_t dim1, size_t... dim>
bool regina::TableView< Element, dim1, dim >::iterator::operator!= ( const iterator rhs) const
inline

Compares this with the given iterator for inequality.

Parameters
rhsthe iterator to compare this with.
Returns
false if the iterators point to the same subarray/element of the underlying table, or true if they do not.

◆ operator*()

template<typename Element , size_t dim1, size_t... dim>
Subview regina::TableView< Element, dim1, dim >::iterator::operator* ( ) const
inline

Returns the subarray or element of the underlying table that this iterator is currently pointing to.

The return type follows the same design as TableView::operator[]. For a one-dimensional table it returns the current table element, by const reference. For a multi-dimensional table it returns a TableView of of smaller dimension, by value, representing the slice of the overall table that is obtained when the first array index is fixed at the current iterator position.

Precondition
This iterator is dereferenceable (in particular, it is not past-the-end).
Returns
the corresponding subarray or table element.

◆ operator++() [1/2]

template<typename Element , size_t dim1, size_t... dim>
iterator & regina::TableView< Element, dim1, dim >::iterator::operator++ ( )
inline

The preincrement operator.

Returns
a reference to this iterator after the increment.

◆ operator++() [2/2]

template<typename Element , size_t dim1, size_t... dim>
iterator regina::TableView< Element, dim1, dim >::iterator::operator++ ( int  )
inline

The postincrement operator.

Returns
a copy of this iterator before the increment took place.

◆ operator--() [1/2]

template<typename Element , size_t dim1, size_t... dim>
iterator & regina::TableView< Element, dim1, dim >::iterator::operator-- ( )
inline

The predecrement operator.

Returns
a reference to this iterator after the decrement.

◆ operator--() [2/2]

template<typename Element , size_t dim1, size_t... dim>
iterator regina::TableView< Element, dim1, dim >::iterator::operator-- ( int  )
inline

The postdecrement operator.

Returns
a copy of this iterator before the decrement took place.

◆ operator=()

template<typename Element , size_t dim1, size_t... dim>
iterator & regina::TableView< Element, dim1, dim >::iterator::operator= ( const iterator )
default

Makes this a copy of the given iterator.

Returns
a reference to this iterator.

◆ operator==()

template<typename Element , size_t dim1, size_t... dim>
bool regina::TableView< Element, dim1, dim >::iterator::operator== ( const iterator rhs) const
inline

Compares this with the given iterator for equality.

Parameters
rhsthe iterator to compare this with.
Returns
true if the iterators point to the same subarray/element of the underlying table, or false if they do not.

The documentation for this class was generated from the following file:

Copyright © 1999-2023, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).