Class HexEdgeMap<TData>
Lightweight dictionary wrapper that stores data keyed by HexEdgeCoord. Useful for storing per-edge data such as walls, rivers, or road segments between adjacent hexes.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class HexEdgeMap<TData>
Type Parameters
| Name | Description |
|---|---|
| TData | The type of data stored per edge. May be a reference or value type. |
Remarks
Keys must be canonical HexEdgeCoord values (direction is E, NE, or NW). Non-canonical edge representations (e.g. W, SW, SE edges expressed relative to their own anchor hex) will not match the corresponding canonical key and will be treated as separate entries. Use GetEdgesOfCellNonAlloc(HexCoord, Span<HexEdgeCoord>) to enumerate the six canonical edges of a given cell.
Iteration is allocation-free when performed on the concrete type using
foreach. The value-type HexEdgeMap<TData>.Enumerator is returned by
GetEnumerator() and yields (Coord, Value) tuples in dictionary
insertion order (not guaranteed to be stable across .NET versions).
Constructors
HexEdgeMap()
Creates a new empty hex edge map with the default initial capacity.
Declaration
public HexEdgeMap()
HexEdgeMap(int)
Creates a new empty hex edge map with the specified initial capacity. Pre-sizing avoids resize allocations when the approximate number of edges is known in advance.
Declaration
public HexEdgeMap(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial capacity of the underlying dictionary. Must be non-negative. A capacity of 0 is treated as the default initial capacity. |
Properties
Count
Gets the number of edges that currently have data stored in this map.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Removes all stored edge data from this map, resetting Count to zero.
Declaration
public void Clear()
Contains(HexEdgeCoord)
Determines whether any data has been stored at the specified canonical edge coordinate.
Declaration
public bool Contains(HexEdgeCoord coord)
Parameters
| Type | Name | Description |
|---|---|---|
| HexEdgeCoord | coord | The edge coordinate to check. |
Returns
| Type | Description |
|---|---|
| bool |
GetEnumerator()
Returns a value-type HexEdgeMap<TData>.Enumerator that iterates through all stored edge data without allocating on the heap when used with foreach on the concrete type.
Declaration
public HexEdgeMap<TData>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| HexEdgeMap<TData>.Enumerator | An HexEdgeMap<TData>.Enumerator for allocation-free iteration over (Coord, Value) pairs. |
Set(HexEdgeCoord, TData)
Stores value at the specified edge coordinate, inserting a new entry
or overwriting any existing entry.
Declaration
public void Set(HexEdgeCoord coord, TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexEdgeCoord | coord | The canonical edge coordinate at which to store the data. |
| TData | value | The data to associate with this edge. |
TryGet(HexEdgeCoord, out TData)
Attempts to retrieve the data stored at the specified canonical edge coordinate.
Declaration
public bool TryGet(HexEdgeCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexEdgeCoord | coord | The canonical edge coordinate to look up. |
| TData | value | When this method returns, contains the data associated with |
Returns
| Type | Description |
|---|---|
| bool |
TryRemove(HexEdgeCoord, out TData)
Attempts to remove the data stored at the specified canonical edge coordinate.
Declaration
public bool TryRemove(HexEdgeCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexEdgeCoord | coord | The edge coordinate to remove. |
| TData | value | When this method returns, contains the removed data if found;
otherwise, contains the default value for |
Returns
| Type | Description |
|---|---|
| bool | true if data was found and removed; false if no entry existed. |