Class SquareCornerMap<TData>
Lightweight dictionary wrapper that stores arbitrary data keyed by SquareCornerCoord.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class SquareCornerMap<TData>
Type Parameters
| Name | Description |
|---|---|
| TData | The type of data stored per corner vertex. May be any managed type, including value types, reference types, and nullable value types. |
Remarks
SquareCornerMap<TData> is intended for sparse per-vertex annotations such as
elevation values, resource nodes, decoration markers, or junction costs at grid lattice points.
Only corners that have been explicitly set via Set(SquareCornerCoord, TData) consume memory; absent corners
return nothing from TryGet(SquareCornerCoord, out TData).
Iteration is allocation-free when performed with foreach on the concrete type
because GetEnumerator() returns a value-type SquareCornerMap<TData>.Enumerator.
Constructors
SquareCornerMap()
Creates a new empty square corner map with the default initial capacity.
Declaration
public SquareCornerMap()
SquareCornerMap(int)
Creates a new empty square corner map pre-allocated for at least
capacity entries.
Declaration
public SquareCornerMap(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial number of entries to reserve space for. Providing an accurate estimate avoids rehashing overhead as the map grows. 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 successful Set(SquareCornerCoord, TData) calls that have not been subsequently undone by TryRemove(SquareCornerCoord, out TData) or Clear(). |
Methods
Clear()
Removes all entries from this map, resetting Count to zero.
Declaration
public void Clear()
Remarks
The internal dictionary's capacity is retained after clearing; the underlying memory is not released.
Contains(SquareCornerCoord)
Determines whether data exists at coord.
Declaration
public bool Contains(SquareCornerCoord coord)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareCornerCoord | coord | The corner coordinate to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetEnumerator()
Returns a value-type enumerator that iterates through all populated corner entries.
Declaration
public SquareCornerMap<TData>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| SquareCornerMap<TData>.Enumerator | An SquareCornerMap<TData>.Enumerator positioned before the first entry. Iteration order matches the internal dictionary's unspecified insertion-dependent order. |
Remarks
Because the return type is the concrete value-type SquareCornerMap<TData>.Enumerator (not
IEnumerator<T>), using this method in a foreach loop on the
concrete SquareCornerMap<TData> type avoids heap allocation.
Set(SquareCornerCoord, TData)
Sets the data at coord, inserting a new entry or overwriting an
existing one as needed.
Declaration
public void Set(SquareCornerCoord coord, TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareCornerCoord | coord | The corner coordinate to write. |
| TData | value | The data to associate with |
TryGet(SquareCornerCoord, out TData)
Attempts to retrieve the data stored at coord.
Declaration
public bool TryGet(SquareCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareCornerCoord | coord | The corner coordinate to look up. |
| TData | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
TryRemove(SquareCornerCoord, out TData)
Attempts to remove the entry at coord and retrieve its value.
Declaration
public bool TryRemove(SquareCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| SquareCornerCoord | coord | The corner coordinate to remove. |
| TData | value | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|