OpenTTD Source: VehiclesNearTileXY::Iterator Class Reference

OpenTTD Source 15.3

Public Types | Public Member Functions | Private Member Functions | Private Attributes
VehiclesNearTileXY::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 (int32_t x, int32_t y, uint max_dist)
| 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 | SkipEmptyBuckets ()
| Advance the internal state until we reach a non-empty bucket, or the end.
void | SkipFalseMatches ()
| Advance the internal state until it reaches a vehicle within the search area.

## Private Attributes
Rect | pos_rect
uint | hxmin
uint | hxmax
uint | hymin
uint | hymax
uint | hx
uint | hy
Vehicle * | current_veh

## Detailed Description

Forward iterator.

Definition at line 124 of file vehicle_func.h.

## Member Typedef Documentation

## ◆ difference_type

using VehiclesNearTileXY::Iterator::difference_type = std::ptrdiff_t

Definition at line 127 of file vehicle_func.h.

## ◆ iterator_category

using VehiclesNearTileXY::Iterator::iterator_category = std::forward_iterator_tag

Definition at line 128 of file vehicle_func.h.

## ◆ pointer

using VehiclesNearTileXY::Iterator::pointer = void

Definition at line 129 of file vehicle_func.h.

## ◆ reference

using VehiclesNearTileXY::Iterator::reference = void

Definition at line 130 of file vehicle_func.h.

## ◆ value_type

using VehiclesNearTileXY::Iterator::value_type = Vehicle *

Definition at line 126 of file vehicle_func.h.

## Constructor & Destructor Documentation

## ◆ Iterator()

VehiclesNearTileXY::Iterator::Iterator | ( | int32_t | x,
|  | int32_t | y,
|  | uint | max_dist
| ) |  |
| explicit

Iterator constructor.

Find first vehicle near (x, y).

Definition at line 432 of file vehicle.cpp.

References ComposeTileHash(), GetTileHash1D(), SkipEmptyBuckets(), SkipFalseMatches(), and TILE_SIZE.

## Member Function Documentation

## ◆ Increment()

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

Advance the internal state to the next potential vehicle.

Definition at line 462 of file vehicle.cpp.

## ◆ operator*()

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

Definition at line 137 of file vehicle_func.h.

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

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

Definition at line 139 of file vehicle_func.h.

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

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

Definition at line 146 of file vehicle_func.h.

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

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

Definition at line 134 of file vehicle_func.h.

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

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

Definition at line 135 of file vehicle_func.h.

## ◆ SkipEmptyBuckets()

void VehiclesNearTileXY::Iterator::SkipEmptyBuckets | ( |  | ) |
| private

Advance the internal state until we reach a non-empty bucket, or the end.

Definition at line 472 of file vehicle.cpp.

References ComposeTileHash(), and IncTileHash1D().

Referenced by Iterator().

## ◆ SkipFalseMatches()

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

Advance the internal state until it reaches a vehicle within the search area.

Definition at line 490 of file vehicle.cpp.

Referenced by Iterator().

## Field Documentation

## ◆ current_veh

Vehicle* VehiclesNearTileXY::Iterator::current_veh
| private

Definition at line 156 of file vehicle_func.h.

## ◆ hx

uint VehiclesNearTileXY::Iterator::hx
| private

Definition at line 155 of file vehicle_func.h.

## ◆ hxmax

uint VehiclesNearTileXY::Iterator::hxmax
| private

Definition at line 154 of file vehicle_func.h.

## ◆ hxmin

uint VehiclesNearTileXY::Iterator::hxmin
| private

Definition at line 154 of file vehicle_func.h.

## ◆ hy

uint VehiclesNearTileXY::Iterator::hy
| private

Definition at line 155 of file vehicle_func.h.

## ◆ hymax

uint VehiclesNearTileXY::Iterator::hymax
| private

Definition at line 154 of file vehicle_func.h.

## ◆ hymin

uint VehiclesNearTileXY::Iterator::hymin
| private

Definition at line 154 of file vehicle_func.h.

## ◆ pos_rect

Rect VehiclesNearTileXY::Iterator::pos_rect
| private

Definition at line 153 of file vehicle_func.h.

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

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