Struct RectanglePerimeterPositionsEnumerator
A custom enumerator used to iterate over all positions on the outside edges of a rectangle efficiently.
Generally, you should use PerimeterPositions() to get an instance of this, rather than creating one yourself.
Inherited Members
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public struct RectanglePerimeterPositionsEnumerator : 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 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 SourceRectanglePerimeterPositionsEnumerator(Rectangle)
Creates an enumerator which iterates over all positions on the outside edges of the given rectangle.
Declaration
public RectanglePerimeterPositionsEnumerator(Rectangle rectangle)
Parameters
| Type | Name | Description |
|---|---|---|
| Rectangle | rectangle | A rectangle defining the area to iterate over perimeter for. |
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 RectanglePerimeterPositionsEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| RectanglePerimeterPositionsEnumerator | This enumerator. |
MoveNext()
Advances the iterator to the next position.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool | True if the a new position on the outside of the rectangle was found; false otherwise. |