Class SpatialMap<T>
An implementation of ISpatialMap<T> that allows only one item at each position at a time. If you need multiple items to be able to reside at one location at the same time, use MultiSpatialMap<T> or LayeredSpatialMap<T> instead.
Inherited Members
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class SpatialMap<T> : AdvancedSpatialMap<T>, ISpatialMap<T>, IReadOnlySpatialMap<T>, IEnumerable<ItemPositionPair<T>>, IEnumerable where T : class, IHasID
Type Parameters
Name | Description |
---|---|
T | The type of object that will be contained by this SpatialMap. Must implement IHasID and be a reference-type. |
Remarks
See the ISpatialMap<T> for documentation on the practical purpose of spatial maps.
The objects stored in a SpatialMap<T> must implement IHasID. This is used internally to keep track of the objects, since uints are easily (and efficiently) hashable. If you cannot or do not wish to implement this interface, use AdvancedSpatialMap<T> instead.
Constructors
SpatialMap(IEqualityComparer<Point>, Int32)
Constructor.
Declaration
public SpatialMap(IEqualityComparer<Point> pointComparer = null, int initialCapacity = 32)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<Point> | pointComparer | Equality comparer to use for comparison and hashing of points, as object are added to/removed from/moved around the spatial map. Be especially mindful of the efficiency of its GetHashCode function, as it will determine the efficiency of many SpatialMap functions. Defaults to the default equality comparer for Point. |
Int32 | initialCapacity | The initial maximum number of elements the SpatialMap can hold before it has to internally resize data structures. Defaults to 32. |