Class TriCornerMap<TData>
Lightweight dictionary wrapper that associates arbitrary data with corner vertices in a triangular grid, keyed by TriCornerCoord values.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class TriCornerMap<TData>
Type Parameters
| Name | Description |
|---|---|
| TData | The type of data stored per corner. May be a value type or a reference type. |
Remarks
Typical use cases include storing per-vertex elevation, colour, or marker data. Because corner vertices exist on a dual sublattice with two types (Type I sum=0, Type II sum=1), be consistent about which sublattice type you use as keys; mixing both types for the same geometric vertex would create two separate entries.
Iteration is allocation-free when using the GetEnumerator() method directly on the concrete type (not via an interface), thanks to the value-type TriCornerMap<TData>.Enumerator struct.
Constructors
TriCornerMap()
Creates a new empty TriCornerMap<TData> with the default initial dictionary capacity.
Declaration
public TriCornerMap()
TriCornerMap(int)
Creates a new empty TriCornerMap<TData> with the specified initial capacity, avoiding dictionary resizing for small known-size grids.
Declaration
public TriCornerMap(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 corner vertices 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 TriCornerCoord 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(TriCornerCoord)
Determines whether data has been stored at the specified corner vertex.
Declaration
public bool Contains(TriCornerCoord coord)
Parameters
| Type | Name | Description |
|---|---|---|
| TriCornerCoord | coord | The corner coordinate to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetEnumerator()
Returns an allocation-free enumerator that iterates through all stored corner entries.
Declaration
public TriCornerMap<TData>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| TriCornerMap<TData>.Enumerator | A TriCornerMap<TData>.Enumerator positioned before the first element. |
Remarks
Use this method on the concrete TriCornerMap<TData> type (not via an
interface) to avoid boxing the value-type TriCornerMap<TData>.Enumerator. The standard
foreach statement will resolve to this overload automatically.
Set(TriCornerCoord, TData)
Stores data at the specified corner vertex, adding a new entry or overwriting an existing one.
Declaration
public void Set(TriCornerCoord coord, TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriCornerCoord | coord | The corner coordinate at which to store the data. Should satisfy IsValid for correct behaviour. |
| TData | value | The data value to associate with |
TryGet(TriCornerCoord, out TData)
Attempts to retrieve the data associated with the specified corner vertex.
Declaration
public bool TryGet(TriCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriCornerCoord | coord | The corner coordinate to look up. |
| TData | value | When this method returns, contains the data stored at |
Returns
| Type | Description |
|---|---|
| bool |
|
TryRemove(TriCornerCoord, out TData)
Attempts to remove the data associated with the specified corner vertex.
Declaration
public bool TryRemove(TriCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| TriCornerCoord | coord | The corner coordinate to remove. |
| TData | value | When this method returns, contains the data that was removed if
|
Returns
| Type | Description |
|---|---|
| bool |
|