Class TriEdgeMap<TData>
Lightweight dictionary wrapper that associates arbitrary data with edges in a triangular grid, keyed by canonical TriEdgeCoord values.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class TriEdgeMap<TData>
Type Parameters
| Name | Description |
|---|---|
| TData | The type of data stored per edge. May be a value type or a reference type. |
Remarks
Typical use cases include storing wall flags, passage weights, or other per-edge attributes between adjacent triangle pairs. Because the key is the canonical TriEdgeCoord (downward-anchor form), each real edge maps to exactly one dictionary entry.
Iteration is allocation-free when using the GetEnumerator() method directly on the concrete type (not via an interface), thanks to the value-type TriEdgeMap<TData>.Enumerator struct.
Constructors
TriEdgeMap()
Creates a new empty TriEdgeMap<TData> with the default initial dictionary capacity.
Declaration
public TriEdgeMap()
TriEdgeMap(int)
Creates a new empty TriEdgeMap<TData> with the specified initial capacity, avoiding dictionary resizing for small known-size grids.
Declaration
public TriEdgeMap(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial number of entries the internal dictionary can hold without resizing. Must be non-negative. |
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 | A non-negative integer equal to the number of distinct TriEdgeCoord keys for which data has been set and not subsequently removed. |
Methods
Clear()
Removes all entries from the map, setting Count to zero.
Declaration
public void Clear()
Contains(TriEdgeCoord)
Determines whether data has been stored at the specified edge.
Declaration
public bool Contains(TriEdgeCoord coord)
Parameters
| Type | Name | Description |
|---|---|---|
| TriEdgeCoord | coord | The canonical edge coordinate to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetEnumerator()
Returns an allocation-free enumerator that iterates through all stored edge entries.
Declaration
public TriEdgeMap<TData>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| TriEdgeMap<TData>.Enumerator | A TriEdgeMap<TData>.Enumerator positioned before the first element. |
Remarks
Use this method on the concrete TriEdgeMap<TData> type (not via an
interface) to avoid boxing the value-type TriEdgeMap<TData>.Enumerator. The standard
foreach statement will resolve to this overload automatically.
Set(TriEdgeCoord, TData)
Stores data at the specified edge, adding a new entry or overwriting an existing one.
Declaration
public void Set(TriEdgeCoord coord, TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriEdgeCoord | coord | The canonical edge coordinate at which to store the data. Should satisfy IsValid for correct behaviour. |
| TData | value | The data value to associate with |
TryGet(TriEdgeCoord, out TData)
Attempts to retrieve the data associated with the specified edge.
Declaration
public bool TryGet(TriEdgeCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriEdgeCoord | coord | The canonical edge coordinate to look up. |
| TData | value | When this method returns, contains the data stored at |
Returns
| Type | Description |
|---|---|
| bool |
|
TryRemove(TriEdgeCoord, out TData)
Attempts to remove the data associated with the specified edge.
Declaration
public bool TryRemove(TriEdgeCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriEdgeCoord | coord | The canonical edge coordinate to remove. |
| TData | value | When this method returns, contains the data that was removed if
|
Returns
| Type | Description |
|---|---|
| bool |
|