Struct RectanglePositionsEnumerator
A custom enumerator used to iterate over all positions within a rectangle efficiently.
Inherited Members
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public struct RectanglePositionsEnumerator : IEnumerator<Point>, IEnumerator, IDisposable, IEnumerable<Point>, IEnumerable
Remarks
This type is a struct, and as such is much more efficient when used in a foreach loop than a function returning IEnumerable<Point> by using "yield return". This type does contain implement IEnumerable<T>, so you can pass it to functions which require one (for example, System.LINQ). However, this will have reduced performance due to boxing of the iterator.
Constructors
View SourceRectanglePositionsEnumerator(Rectangle)
Creates an enumerator which iterates over all positions in the given rectangle.
Declaration
public RectanglePositionsEnumerator(Rectangle positions)
Parameters
| Type | Name | Description |
|---|---|---|
| Rectangle | positions | A rectangle containing the positions to iterate over. |
Properties
View SourceCurrent
The current value for enumeration.
Declaration
public Point Current { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Methods
View SourceGetEnumerator()
Returns this enumerator.
Declaration
public RectanglePositionsEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| RectanglePositionsEnumerator | This enumerator. |
MoveNext()
Advances the iterator to the next position.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool | True if the a position within the rectangle was found; false otherwise. |
ToEnumerable()
Obsolete.
Declaration
[Obsolete("This method is obsolete; this structure itself implements IEnumerable directly and provides equivalent behavior, so you should no longer call this function.")]
public IEnumerable<Point> ToEnumerable()
Returns
| Type | Description |
|---|---|
| IEnumerable<Point> |