Delegate NeighborWriter<TCoord>
Delegate for writing the neighbors of a coordinate into a caller-supplied span buffer. Required because Span<T> is a ref struct and therefore cannot be used as a generic type argument in Func<T, TResult> or similar delegates.
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public delegate int NeighborWriter<TCoord>(TCoord coord, Span<TCoord> buffer) where TCoord : struct, IEquatable<TCoord>
Parameters
| Type | Name | Description |
|---|---|---|
| TCoord | coord | The coordinate whose neighbors are to be written into |
| Span<TCoord> | buffer | A caller-provided span to receive the neighbor coordinates. The delegate writes up to
|
Returns
| Type | Description |
|---|---|
| int | The number of neighbor coordinates actually written into |
Type Parameters
| Name | Description |
|---|---|
| TCoord | The coordinate type. Must be a value type that implements IEquatable<T>. Typical values are SquareCoord, HexCoord, and TriCoord. |
Remarks
Pass an instance of this delegate to generic algorithms such as
FloodFill<TCoord>(TCoord, Func<TCoord, bool>, NeighborWriter<TCoord>, TCoord[], HashSet<TCoord>, Queue<TCoord>) to decouple grid topology from the algorithm.
Typical implementations are obtained from the concrete grid's
GetNeighborsNonAlloc method or from GetEdgeNeighbors(TriCoord, Span<TriCoord>).