Class LayerMaskEnumerator
A type designed to be returned from Layers(UInt32) in order to enumerate over a set of layers in a layer mask efficiently.
Namespace: SadRogue.Primitives.SpatialMaps
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class LayerMaskEnumerator : ValueType, IEnumerator<int>, IEnumerator, IDisposable, IEnumerable<int>, IEnumerable
Remarks
This type is a struct, and as such is much more efficient than using the otherwise equivalent type of IEnumerable<int> with "yield return". The type does also implement IEnumerable<T>, so it can be used with functions that require one (like System.LINQ); however using this function is not recommended in situations where runtime performance is a primary concern.
This iterator will enumerate the layers in reverse order; ie. highest active number to lowest active number.
Constructors
LayerMaskEnumerator(UInt32, Int32)
Constructs a new enumerator.
Declaration
public LayerMaskEnumerator(uint mask, int numLayers)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | mask | Layer mask to enumerate. |
Int32 | numLayers | Number of layers to be considered within the mask. |
Properties
Current
The current value for enumeration.
Declaration
public int Current { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
GetEnumerator()
Returns this enumerator.
Declaration
public LayerMaskEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
LayerMaskEnumerator | This enumerator. |
MoveNext()
Advances the iterator to the next active layer.
Declaration
public bool MoveNext()
Returns
Type | Description |
---|---|
Boolean | True if an active layer was found; false otherwise. |