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
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
Lookahead(int)
Look ahead (offset >= 0) without advancing. Returns an Option<T>.
public Option<T> Lookahead(int offset)
Parameters
offsetint
Returns
- Option<T>
Peek(out T)
Peek the next element without advancing.
public bool Peek(out T value)
Parameters
valueT
Returns
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
valueTThe next value when present.
nextReplayableSequence<T>.CursorThe advanced cursor (only valid when result is true).