载入中...
搜索中...
未找到
eve::hexmap::HexSearchContext类 参考

Reusable search scratch: one record per cell plus a priority bucket queue. 更多...

#include <HexSearch.h>

Public 成员函数

 HexSearchContext ()=default
 Hex search context.
 
void resize (std::int32_t cellCount)
 Sizes the scratch for cellCount cells, preserving nothing.
 
std::int32_t cellCount () const noexcept
 Number of cells this context can hold.
 
HexSearchData & data (std::int32_t cellIndex) noexcept
 Mutable record of one cell.
 
const HexSearchData & data (std::int32_t cellIndex) const noexcept
 Const overload of data.
 
std::int32_t beginPhase () noexcept
 Starts a new search: clears the frontier and advances the phase.
 
std::int32_t phase () const noexcept
 Current phase.
 
void enqueue (std::int32_t cellIndex) noexcept
 Adds a cell at its current priority.
 
HexSearchPop dequeue (std::int32_t &outCellIndex) noexcept
 Removes the lowest-priority cell.
 
void change (std::int32_t cellIndex, std::int32_t oldPriority) noexcept
 Re-queues a cell whose priority changed after it was enqueued.
 

详细描述

Reusable search scratch: one record per cell plus a priority bucket queue.

The queue is the reference project's bucket-list frontier: an array indexed by priority, where equal-priority cells form an intrusive singly linked list through HexSearchData::nextWithSamePriority. Priorities are small bounded integers - move costs and step counts - so a bucket list beats a binary heap here and needs no comparison function.

Ownership and lifetime: owns plain host memory sized to cellCount. It is a scratch buffer, not a result: callers may reuse one instance across searches and across maps of the same size.

Thread affinity: no thread safety; a context must not be shared between concurrent searches.

在文件 HexSearch.h 第 68 行定义.

构造及析构函数说明

◆ HexSearchContext()

eve::hexmap::HexSearchContext::HexSearchContext ( )
default

Hex search context.

成员函数说明

◆ beginPhase()

std::int32_t eve::hexmap::HexSearchContext::beginPhase ( )
noexcept

Starts a new search: clears the frontier and advances the phase.

返回
The new phase; records whose searchPhase differs are unvisited.
注解
Phases advance by two so a cell can be marked "in the frontier" and "expanded" by two distinct values, matching the reference algorithm.

在文件 HexSearch.cpp 第 60 行定义.

被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().

◆ cellCount()

std::int32_t eve::hexmap::HexSearchContext::cellCount ( ) const
inlinenoexcept

Number of cells this context can hold.

在文件 HexSearch.h 第 80 行定义.

被这些函数引用 eve::hexmap::collectVisibleCells(), eve::hexmap::findPath() , 以及 resize().

◆ change()

void eve::hexmap::HexSearchContext::change ( std::int32_t  cellIndex,
std::int32_t  oldPriority 
)
noexcept

Re-queues a cell whose priority changed after it was enqueued.

参数
cellIndexCell to move.
oldPriorityPriority the cell was enqueued with.

在文件 HexSearch.cpp 第 114 行定义.

被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().

◆ data() [1/2]

const HexSearchData & eve::hexmap::HexSearchContext::data ( std::int32_t  cellIndex) const
noexcept

Const overload of data.

在文件 HexSearch.cpp 第 55 行定义.

◆ data() [2/2]

HexSearchData & eve::hexmap::HexSearchContext::data ( std::int32_t  cellIndex)
noexcept

Mutable record of one cell.

参数
cellIndexLinear cell index in [0, cellCount()).
返回
The record; out-of-range indices return a shared sink record.

在文件 HexSearch.cpp 第 50 行定义.

被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().

◆ dequeue()

HexSearchPop eve::hexmap::HexSearchContext::dequeue ( std::int32_t &  outCellIndex)
noexcept

Removes the lowest-priority cell.

参数
outCellIndexReceives the cell index; untouched when the frontier is empty.
返回
Cell when a cell was popped, Empty when the frontier ran dry.

在文件 HexSearch.cpp 第 83 行定义.

引用了 eve::hexmap::Cell , 以及 eve::hexmap::Empty.

被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().

◆ enqueue()

void eve::hexmap::HexSearchContext::enqueue ( std::int32_t  cellIndex)
noexcept

Adds a cell at its current priority.

在文件 HexSearch.cpp 第 70 行定义.

引用了 priority.

被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().

◆ phase()

std::int32_t eve::hexmap::HexSearchContext::phase ( ) const
inlinenoexcept

Current phase.

在文件 HexSearch.h 第 100 行定义.

◆ resize()

void eve::hexmap::HexSearchContext::resize ( std::int32_t  cellCount)

Sizes the scratch for cellCount cells, preserving nothing.

参数
cellCountNumber of cells of the map this context searches.

在文件 HexSearch.cpp 第 40 行定义.

引用了 cellCount().

被这些函数引用 eve::hexmap::HexMapModule::syncScratch().


该类的文档由以下文件生成: