Class CirclePositionsEnumerator
A custom enumerator used to iterate over all positions on the outside of a circle efficiently.
Generally, you should use GetCircle(Point, Int32) to get an instance of this, rather than creating one yourself.
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class CirclePositionsEnumerator : ValueType, 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
CirclePositionsEnumerator(Point, Int32)
Creates an enumerator which iterates over all positions on the outside of the given circle.
Declaration
public CirclePositionsEnumerator(Point center, int radius)
Parameters
Type | Name | Description |
---|---|---|
Point | center | Center of the circle. |
Int32 | radius | The radius of the circle. |
Properties
Current
The current value for enumeration.
Declaration
public Point Current { get; }
Property Value
Type | Description |
---|---|
Point |
Methods
GetEnumerator()
Returns this enumerator.
Declaration
public CirclePositionsEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
CirclePositionsEnumerator | This enumerator. |
MoveNext()
Advances the iterator to the next position.
Declaration
public bool MoveNext()
Returns
Type | Description |
---|---|
Boolean | True if the a new position on the outside of the circle exists; false otherwise. |
ToEnumerable()
Obsolete.
Declaration
public IEnumerable<Point> ToEnumerable()
Returns
Type | Description |
---|---|
IEnumerable<Point> |