OpenTTD Source: CSegmentCostCacheT< Tsegment > Struct Template Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Data Fields | Static Public Attributes
CSegmentCostCacheT< Tsegment > Struct Template Reference

CSegmentCostCacheT - template class providing hash-map and storage (heap) of Tsegment structures. More...

`#include <yapf_costcache.hpp>`

Inheritance diagram for CSegmentCostCacheT< Tsegment >:

## Public Types
using | Key = typename Tsegment::Key
| key to hash table

## Public Member Functions
void | Flush ()
| flush (clear) the cache
Tsegment & | Get (Key &key, bool *found)

## Data Fields
HashTable< Tsegment, HASH_BITS > | map
std::deque< Tsegment > | heap

## Static Public Attributes
static constexpr int | HASH_BITS = 14
Static Public Attributes inherited from CSegmentCostCacheBase
static int | s_rail_change_counter = 0
| if any track changes, this counter is incremented - that will invalidate segment cost cache

## Additional Inherited Members
Static Public Member Functions inherited from CSegmentCostCacheBase
static void | NotifyTrackLayoutChange (TileIndex, Track)

## Detailed Description

template<class Tsegment>
struct CSegmentCostCacheT< Tsegment >

CSegmentCostCacheT - template class providing hash-map and storage (heap) of Tsegment structures.

Each rail node contains pointer to the segment that contains cached (or non-cached) segment cost information. Nodes can differ by key type, but they use the same segment type. Segment key should be always the same (TileIndex + DiagDirection) that represent the beginning of the segment (origin tile and exit-dir from this tile). Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT. Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example

Definition at line 66 of file yapf_costcache.hpp.

## Member Typedef Documentation

## ◆ Key

template<class Tsegment >

using CSegmentCostCacheT< Tsegment >::Key = typename Tsegment::Key

key to hash table

Definition at line 69 of file yapf_costcache.hpp.

## Constructor & Destructor Documentation

## ◆ CSegmentCostCacheT()

template<class Tsegment >

CSegmentCostCacheT< Tsegment >::CSegmentCostCacheT | ( |  | ) |
| inline

Definition at line 74 of file yapf_costcache.hpp.

## Member Function Documentation

## ◆ Flush()

template<class Tsegment >

void CSegmentCostCacheT< Tsegment >::Flush | ( |  | ) |
| inline

flush (clear) the cache

Definition at line 77 of file yapf_costcache.hpp.

References HashTable< Titem, Thash_bits_ >::Clear().

## ◆ Get()

template<class Tsegment >

Tsegment & CSegmentCostCacheT< Tsegment >::Get | ( | Key & | key,
|  | bool * | found
| ) |  |
| inline

Definition at line 83 of file yapf_costcache.hpp.

## Field Documentation

## ◆ HASH_BITS

template<class Tsegment >

constexpr int CSegmentCostCacheT< Tsegment >::HASH_BITS = 14
| staticconstexpr

Definition at line 67 of file yapf_costcache.hpp.

## ◆ heap

template<class Tsegment >

std::deque<Tsegment> CSegmentCostCacheT< Tsegment >::heap

Definition at line 72 of file yapf_costcache.hpp.

## ◆ map

template<class Tsegment >

HashTable<Tsegment, HASH_BITS> CSegmentCostCacheT< Tsegment >::map

Definition at line 71 of file yapf_costcache.hpp.

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

- src/pathfinder/yapf/yapf_costcache.hpp