base class · System

Iterator<T>

public base class Iterator<T>

The values of a function with yield, made one at a time: each Next() runs the function on to its next yield. loop (T x in F()) walks them. An iterator runs once (call the function again to start over).

Kind
base class
Namespace
System
Assembly
System.Core
Access
public, abstract
Source file
Iterator.ant

Type parameters

NameConstraints
Tany type

Inheritance

Base classes
Any Iterator<T>

Properties

T Current { get; }
#

read-only

The value Next() moved to.

Methods

Next() : bool
#

abstract

Runs on to the next value: false when the function has ended (and from then on).

Dispose()
#

Ends the iterator before its last value: the finally blocks around the yield it paused at run (as they do when it ends on its own), and Next() gives false from then on. Nothing happens to one that has ended.

Itself: loop (T x in iterator) walks what is left of it.

Fields

T current
#

inherited

The value the last yield gave.

bool disposing
#

inherited

Set by Dispose(): the next step runs the finally blocks around the last yield and ends.

Inherited members (5)

Source

Iterator<T> as Antril, decompiled from its Larva HIR.

System.Iterator.ant
// System.Iterator — System.Core (decompiled from Larva HIR)

into namespace System
{
	/// The values of a function with `yield`, made one at a time: each `Next()` runs the function on to its next
	/// `yield`. `loop (T x in F())` walks them. An iterator runs once (call the function again to start over).
	public base class Iterator<T>
	{
		inherited:
			/// The value the last `yield` gave.
			T current;

			/// Set by `Dispose()`: the next step runs the `finally` blocks around the last `yield` and ends.
			bool disposing;

		public:
			/// Runs on to the next value: false when the function has ended (and from then on).
			Next() : bool;

			/// Ends the iterator before its last value: the `finally` blocks around the `yield` it paused at run (as they
			/// do when it ends on its own), and `Next()` gives false from then on. Nothing happens to one that has ended.
			Dispose()
			{
				disposing = true;
				Next();
			}

			/// Itself: `loop (T x in iterator)` walks what is left of it.
			Iterator() : Iterator<T> => this;

			/// The value `Next()` moved to.
			T Current
			{
				get => current;
			}
	}
}
Esc