Class AutoSyncSpatialMap<T>
A version of SpatialMap<T> which takes items that implement IPositionable, and uses that interface's properties/events to automatically ensure items are recorded at the proper positions in the spatial map when they move and that the position fields are updated if the spatial map's move functions are used.
Inherited Members
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class AutoSyncSpatialMap<T> : AutoSyncAdvancedSpatialMap<T>, ISpatialMap<T>, IReadOnlySpatialMap<T>, IEnumerable<ItemPositionPair<T>>, IEnumerable where T : class, IHasID, IPositionable
Type Parameters
Name | Description |
---|---|
T | The type of object that will be contained by this spatial map. |
Remarks
This class automatically keeps the spatial map position of each object synced up with their Position property; you may either use the Move functions of the spatial map, in which case the Position fields of the objects are updated as appropriate, or you may change the Position field, in which case the spatial map position is updated to match.
If you want to manually control the positions of items in the spatial map, you should use SpatialMap<T> instead.
Constructors
AutoSyncSpatialMap(IEqualityComparer<Point>, Int32)
Constructor.
Declaration
public AutoSyncSpatialMap(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. |