OpenTTD Source 20260311-master-g511d3794ce
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
Vehicleoperator* () const
Iteratoroperator++ ()
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
Vehiclecurrent

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.

Parameters
tileThe tile to find the vehicles on.

Definition at line 528 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 538 of file vehicle.cpp.

Referenced by SkipFalseMatches().

◆ 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 546 of file vehicle.cpp.

References Increment().

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: