OpenTTD Source: VehiclesOnTile::Iterator Class Reference

OpenTTD Source 15.3

Public Types | Public Member Functions | Private Member Functions | Private Attributes
VehiclesOnTile::Iterator Class Reference

Forward iterator. More...

`#include <vehicle_func.h>`

## Public Types
using | value_type = Vehicle *
using | difference_type = std::ptrdiff_t
using | iterator_category = std::forward_iterator_tag
using | pointer = void
using | reference = void

## Public Member Functions
| Iterator (TileIndex tile)
| Iterator constructor.
bool | operator== (const Iterator &rhs) const
bool | operator== (const std::default_sentinel_t &) const
Vehicle * | operator* () const
Iterator & | operator++ ()
Iterator | operator++ (int)

## Private Member Functions
void | Increment ()
| Advance the internal state to the next potential vehicle.
void | SkipFalseMatches ()
| Advance the internal state until it reaches a vehicle on the correct tile or the end.

## Private Attributes
TileIndex | tile
Vehicle * | current

## Detailed Description

Forward iterator.

Definition at line 58 of file vehicle_func.h.

## Member Typedef Documentation

## ◆ difference_type

using VehiclesOnTile::Iterator::difference_type = std::ptrdiff_t

Definition at line 61 of file vehicle_func.h.

## ◆ iterator_category

using VehiclesOnTile::Iterator::iterator_category = std::forward_iterator_tag

Definition at line 62 of file vehicle_func.h.

## ◆ pointer

using VehiclesOnTile::Iterator::pointer = void

Definition at line 63 of file vehicle_func.h.

## ◆ reference

using VehiclesOnTile::Iterator::reference = void

Definition at line 64 of file vehicle_func.h.

## ◆ value_type

using VehiclesOnTile::Iterator::value_type = Vehicle *

Definition at line 60 of file vehicle_func.h.

## Constructor & Destructor Documentation

## ◆ Iterator()

VehiclesOnTile::Iterator::Iterator | ( | TileIndex | tile | ) |
| explicit

Iterator constructor.

Find first vehicle on tile.

Definition at line 499 of file vehicle.cpp.

References GetTileHash(), SkipFalseMatches(), TileX(), and TileY().

## Member Function Documentation

## ◆ Increment()

void VehiclesOnTile::Iterator::Increment | ( |  | ) |
| private

Advance the internal state to the next potential vehicle.

The vehicle may not be on the correct tile though.

Definition at line 509 of file vehicle.cpp.

## ◆ operator*()

Vehicle * VehiclesOnTile::Iterator::operator* | ( |  | ) | const
| inline

Definition at line 71 of file vehicle_func.h.

## ◆ operator++() [1/2]

Iterator & VehiclesOnTile::Iterator::operator++ | ( |  | ) |
| inline

Definition at line 73 of file vehicle_func.h.

## ◆ operator++() [2/2]

Iterator VehiclesOnTile::Iterator::operator++ | ( | int |  | ) |
| inline

Definition at line 80 of file vehicle_func.h.

## ◆ operator==() [1/2]

bool VehiclesOnTile::Iterator::operator== | ( | const Iterator & | rhs | ) | const
| inline

Definition at line 68 of file vehicle_func.h.

## ◆ operator==() [2/2]

bool VehiclesOnTile::Iterator::operator== | ( | const std::default_sentinel_t & |  | ) | const
| inline

Definition at line 69 of file vehicle_func.h.

## ◆ SkipFalseMatches()

void VehiclesOnTile::Iterator::SkipFalseMatches | ( |  | ) |
| private

Advance the internal state until it reaches a vehicle on the correct tile or the end.

Definition at line 517 of file vehicle.cpp.

Referenced by Iterator().

## Field Documentation

## ◆ current

Vehicle* VehiclesOnTile::Iterator::current
| private

Definition at line 88 of file vehicle_func.h.

## ◆ tile

TileIndex VehiclesOnTile::Iterator::tile
| private

Definition at line 87 of file vehicle_func.h.

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

- src/vehicle_func.h
- src/vehicle.cpp