Class AutoSyncMultiSpatialMap<T>
A version of MultiSpatialMap<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 AutoSyncMultiSpatialMap<T> : AutoSyncAdvancedMultiSpatialMap<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 MultiSpatialMap<T> instead.
Constructors
AutoSyncMultiSpatialMap(IListPool<T>, IEqualityComparer<Point>, Int32)
Constructor.
Declaration
public AutoSyncMultiSpatialMap(IListPool<T> listPool, IEqualityComparer<Point> pointComparer = null, int initialCapacity = 32)
Parameters
Type | Name | Description |
---|---|---|
IListPool<T> | listPool | The list pool implementation to use. Specify NoPoolingListPool<T> to disable pooling entirely. This implementation may be shared with other spatial maps if you wish, however be aware that no thread safety is implemented by the default list pool implementations or the spatial map itself. |
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 MultiSpatialMap functions. Defaults to the default equality comparer for Point, which uses a fairly efficient generalized hashing algorithm. |
Int32 | initialCapacity | The initial maximum number of elements the spatial map can hold before it has to internally resize data structures. Defaults to 32. |
AutoSyncMultiSpatialMap(IEqualityComparer<Point>, Int32)
Constructor.
Declaration
public AutoSyncMultiSpatialMap(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 MultiSpatialMap functions. Defaults to the default equality comparer for Point, which uses a fairly efficient generalized hashing algorithm. |
Int32 | initialCapacity | The initial maximum number of elements the spatial map can hold before it has to internally resize data structures. Defaults to 32. |