Skip to content

LinkedListCursor

Defined in: packages/data/src/list/linked-list.ts:37

A cursor over a LinkedList.

Forward-only, matching what a singly-linked list can honour in O(1): there is no retreat, and insertAfter/removeAfter operate on the node this cursor points at without walking the list from the head.

A cursor’s element was removed — by any means, not just through this cursor — is exactly when valid becomes false; the underlying node is marked on removal, and every cursor still referencing it observes that mark. A cursor obtained from end() has no node of its own: insertAfter on it appends, reading the list’s current tail live, so it never goes stale even if other insertions/removals happen first.

T extends DefinedValue

The type of elements in the list.

new LinkedListCursor<T>(list, node): LinkedListCursor<T>

Defined in: packages/data/src/list/linked-list.ts:38

LinkedList<T>

LinkedListNode_<T> | null

LinkedListCursor<T>

get valid(): boolean

Defined in: packages/data/src/list/linked-list.ts:43

False once moved past the end, or once its element was removed.

boolean

False once moved past the end, or once its element was removed.

ICursor.valid


get value(): T | undefined

Defined in: packages/data/src/list/linked-list.ts:47

The element at this position, undefined when not valid.

T | undefined

The element at this position, undefined when not valid.

ICursor.value

advance(): boolean

Defined in: packages/data/src/list/linked-list.ts:51

Moves one position forward.

boolean

false if that moved past the end.

ICursor.advance


clone(): LinkedListCursor<T>

Defined in: packages/data/src/list/linked-list.ts:60

An independent cursor at the same position.

LinkedListCursor<T>

ICursor.clone