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()
|
default |
Hex search context.
成员函数说明
◆ beginPhase()
|
noexcept |
Starts a new search: clears the frontier and advances the phase.
- 返回
- The new phase; records whose
searchPhasediffers 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()
|
inlinenoexcept |
Number of cells this context can hold.
在文件 HexSearch.h 第 80 行定义.
被这些函数引用 eve::hexmap::collectVisibleCells(), eve::hexmap::findPath() , 以及 resize().
◆ change()
|
noexcept |
Re-queues a cell whose priority changed after it was enqueued.
- 参数
-
cellIndex Cell to move. oldPriority Priority the cell was enqueued with.
在文件 HexSearch.cpp 第 114 行定义.
被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().
◆ data() [1/2]
|
noexcept |
Const overload of data.
在文件 HexSearch.cpp 第 55 行定义.
◆ data() [2/2]
|
noexcept |
Mutable record of one cell.
- 参数
-
cellIndex Linear 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()
|
noexcept |
Removes the lowest-priority cell.
- 参数
-
outCellIndex Receives the cell index; untouched when the frontier is empty.
- 返回
Cellwhen a cell was popped,Emptywhen the frontier ran dry.
在文件 HexSearch.cpp 第 83 行定义.
引用了 eve::hexmap::Cell , 以及 eve::hexmap::Empty.
被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().
◆ enqueue()
|
noexcept |
Adds a cell at its current priority.
在文件 HexSearch.cpp 第 70 行定义.
引用了 priority.
被这些函数引用 eve::hexmap::collectVisibleCells() , 以及 eve::hexmap::findPath().
◆ phase()
|
inlinenoexcept |
Current phase.
在文件 HexSearch.h 第 100 行定义.
◆ resize()
| void eve::hexmap::HexSearchContext::resize | ( | std::int32_t | cellCount | ) |
Sizes the scratch for cellCount cells, preserving nothing.
- 参数
-
cellCount Number of cells of the map this context searches.
在文件 HexSearch.cpp 第 40 行定义.
引用了 cellCount().
该类的文档由以下文件生成:
- src/modules/hexmap/HexSearch.h
- src/modules/hexmap/HexSearch.cpp