Table of Contents

Struct ReplayableSequence<T>.Cursor

Namespace
PatternKit.Behavioral.Iterator
Assembly
PatternKit.Core.dll

A lightweight position inside a ReplayableSequence<T>. Value-type; copying is cheap.

public readonly struct ReplayableSequence<T>.Cursor
Inherited Members
Extension Methods

Remarks

Enumerating via a cursor is non-destructive to other cursors; all share the underlying buffer.

Properties

Position

Current (next) index (0-based) inside the sequence.

public int Position { get; }

Property Value

int

Methods

AsEnumerable()

Enumerate from this position forward as an IEnumerable<T>. The original cursor is not advanced (a copy is enumerated).

public IEnumerable<T> AsEnumerable()

Returns

IEnumerable<T>

Fork()

Create an independent cursor at the same position.

public ReplayableSequence<T>.Cursor Fork()

Returns

ReplayableSequence<T>.Cursor

Lookahead(int)

Look ahead (offset >= 0) without advancing. Returns an Option<T>.

public Option<T> Lookahead(int offset)

Parameters

offset int

Returns

Option<T>

Peek(out T)

Peek the next element without advancing.

public bool Peek(out T value)

Parameters

value T

Returns

bool

TryNext(out T, out Cursor)

Try to read the next element. Returns an advanced cursor when successful.

public bool TryNext(out T value, out ReplayableSequence<T>.Cursor next)

Parameters

value T

The next value when present.

next ReplayableSequence<T>.Cursor

The advanced cursor (only valid when result is true).

Returns

bool

true when an element was available; otherwise false.