Show / Hide Table of Contents

Class BresenhamEnumerator

A custom enumerator used to iterate over all positions on the on a line using the Bresenham line algorithm efficiently.

Generally, you should use GetBresenhamLine(Point, Point) to get an instance of this, rather than creating one yourself.

Inheritance
Object
BresenhamEnumerator
Implements
IEnumerator<Point>
IEnumerator
IDisposable
IEnumerable<Point>
IEnumerable
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class BresenhamEnumerator : 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

BresenhamEnumerator(Point, Point)

Creates an enumerator which iterates over all positions on the line.

Declaration
public BresenhamEnumerator(Point start, Point end)
Parameters
Type Name Description
Point start

Starting point for the line.

Point end

Ending point for the line.

Properties

Current

The current value for enumeration.

Declaration
public Point Current { get; }
Property Value
Type Description
Point

Methods

GetEnumerator()

Returns this enumerator.

Declaration
public BresenhamEnumerator GetEnumerator()
Returns
Type Description
BresenhamEnumerator

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 line exists; false otherwise.

ToEnumerable()

Obsolete.

Declaration
public IEnumerable<Point> ToEnumerable()
Returns
Type Description
IEnumerable<Point>

Implements

System.Collections.Generic.IEnumerator<T>
System.Collections.IEnumerator
System.IDisposable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX