OpenTTD Source 20261112-master-gbcbec5e63f
OrthogonalTileArea::iterator Class Reference

Iterator to iterate over a tile area (rectangle) of the map. More...

#include <tilearea_orthogonal.h>

Public Types

using value_type = TileIndex
 value_type iterator trait
using difference_type = std::ptrdiff_t
 difference_type iterator trait
using iterator_category = std::forward_iterator_tag
 iterator_category iterator trait
using pointer = void
 pointer iterator trait
using reference = void
 reference iterator trait

Public Member Functions

 iterator (const OrthogonalTileArea &ta)
 Construct the iterator.
bool operator== (const iterator &) const =default
 Compare with other iterator.
bool operator== (const std::default_sentinel_t &) const
 Compare with end sentinel.
TileIndex operator* () const
 Get the current tile.
iterator & operator++ ()
 Increment the iterator and set it to the next position.

Private Attributes

TileIndex tile
 The current tile.
int w
 The width of the iterated area.
int x
 The current 'x' position in the rectangle.
int y
 The current 'y' position in the rectangle.

Detailed Description

Iterator to iterate over a tile area (rectangle) of the map.

Definition at line 79 of file tilearea_orthogonal.h.

Member Typedef Documentation

◆ difference_type

difference_type iterator trait

Definition at line 88 of file tilearea_orthogonal.h.

◆ iterator_category

using OrthogonalTileArea::iterator::iterator_category = std::forward_iterator_tag

iterator_category iterator trait

Definition at line 89 of file tilearea_orthogonal.h.

◆ pointer

pointer iterator trait

Definition at line 90 of file tilearea_orthogonal.h.

◆ reference

reference iterator trait

Definition at line 91 of file tilearea_orthogonal.h.

◆ value_type

value_type iterator trait

Definition at line 87 of file tilearea_orthogonal.h.

Constructor & Destructor Documentation

◆ iterator()

OrthogonalTileArea::iterator::iterator ( const OrthogonalTileArea & ta)
inlineexplicit

Construct the iterator.

Parameters
taArea, i.e. begin point and width/height of to-be-iterated area.

Definition at line 97 of file tilearea_orthogonal.h.

References OrthogonalTileArea::h, INVALID_TILE, OrthogonalTileArea::OrthogonalTileArea(), tile, w, x, and y.

Referenced by operator++(), and operator==().

Member Function Documentation

◆ operator*()

TileIndex OrthogonalTileArea::iterator::operator* ( ) const
inline

Get the current tile.

Returns
The current tile, or INVALID_TILE when complete.

Definition at line 118 of file tilearea_orthogonal.h.

◆ operator++()

iterator & OrthogonalTileArea::iterator::operator++ ( )
inline

Increment the iterator and set it to the next position.

Returns
This iterator after incrementing.

Definition at line 127 of file tilearea_orthogonal.h.

References INVALID_TILE, iterator(), and TileDiffXY().

◆ operator==() [1/2]

bool OrthogonalTileArea::iterator::operator== ( const iterator & ) const
default

Compare with other iterator.

Returns
true iff the other iterator matches this value.

References iterator().

◆ operator==() [2/2]

bool OrthogonalTileArea::iterator::operator== ( const std::default_sentinel_t & ) const
inline

Compare with end sentinel.

Returns
true iff this iterator is at the end.

Definition at line 109 of file tilearea_orthogonal.h.

References INVALID_TILE.

Field Documentation

◆ tile

TileIndex OrthogonalTileArea::iterator::tile
private

The current tile.

Definition at line 81 of file tilearea_orthogonal.h.

Referenced by iterator().

◆ w

int OrthogonalTileArea::iterator::w
private

The width of the iterated area.

Definition at line 82 of file tilearea_orthogonal.h.

Referenced by iterator().

◆ x

int OrthogonalTileArea::iterator::x
private

The current 'x' position in the rectangle.

Definition at line 83 of file tilearea_orthogonal.h.

Referenced by iterator().

◆ y

int OrthogonalTileArea::iterator::y
private

The current 'y' position in the rectangle.

Definition at line 84 of file tilearea_orthogonal.h.

Referenced by iterator().


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