Skip to content

IndexCursorSequence

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:42

IBidirectionalCursorSequence implementation.

Every live cursor is tracked via a WeakRef, so it costs nothing once the cursor itself becomes unreachable. Each structural mutation walks the registry once (notifyMutation/notifyClear, called by the host) and shifts or invalidates every entry — this is what lets an IRandomAccessCursor auto-adjust instead of silently reading a shifted element after an insertion/removal elsewhere in the same list.

A cursor past the end (from end(), or having advanced off the tail) is !valid but keeps tracking the list’s current count() through further mutations, the same way retreat()-ing from it always reaches whatever is currently the last element. A cursor whose specific element was deleted is !valid too, but permanently: its index is frozen, advance/retreat/ seek refuse to move it, and passing it to any ICursorSequence mutator throws, rather than silently acting on a stale, unrelated position.

T extends DefinedValue

new IndexCursorSequence<T>(host): IndexCursorSequence<T>

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:47

IndexCursorHost<T>

IndexCursorSequence<T>

begin(): IRandomAccessCursor<T>

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:49

The first element; invalid when empty.

IRandomAccessCursor<T>

IBidirectionalCursorSequence.begin


cursorAt(index): IRandomAccessCursor<T>

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:57

O(1) for random-access backings, O(n) otherwise.

number

IRandomAccessCursor<T>

IBidirectionalCursorSequence.cursorAt


end(): IRandomAccessCursor<T>

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:53

The past-the-end position, used to append.

IRandomAccessCursor<T>

IBidirectionalCursorSequence.end


insertAfter(cursor, item): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:64

Inserts an item after cursor. O(1).

IRandomAccessCursor<T>

The position after which to insert.

T

The item to insert.

void

IBidirectionalCursorSequence.insertAfter


insertAllAfter(cursor, items): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:71

Inserts every item after cursor, keeping their relative order. O(n) in the number of items.

IRandomAccessCursor<T>

The position after which to insert.

readonly T[]

The items to insert.

void

IBidirectionalCursorSequence.insertAllAfter


insertAllBefore(cursor, items): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:84

Inserts every item before cursor, keeping their relative order. O(n) in the number of items.

IRandomAccessCursor<T>

The position before which to insert.

readonly T[]

The items to insert.

void

IBidirectionalCursorSequence.insertAllBefore


insertBefore(cursor, item): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:78

Inserts an item before cursor. O(1).

IRandomAccessCursor<T>

The position before which to insert.

T

The item to insert.

void

IBidirectionalCursorSequence.insertBefore


notifyClear(): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:147

Called by the host after every clear.

void


notifyMutation(at, deleteCount, insertCount): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:118

Called by the host after every splice/append-only set.

number

number

number

void


removeAfter(cursor): T | undefined

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:90

Removes the element after cursor. O(1). Cursors at the removed element become invalid.

IRandomAccessCursor<T>

The position before the element to remove.

T | undefined

The removed element, or undefined if there was none.

IBidirectionalCursorSequence.removeAfter


removeAt(cursor): T | undefined

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:97

Removes the element at cursor. O(1). Cursors at the removed element become invalid.

IRandomAccessCursor<T>

The position to remove.

T | undefined

The removed element, or undefined if cursor was not valid.

IBidirectionalCursorSequence.removeAt


setAt(cursor, item): void

Defined in: packages/data/src/cursor/index-cursor-sequence.ts:107

Replaces the element at cursor.

IRandomAccessCursor<T>

The position to replace.

T

The new item.

void

IBidirectionalCursorSequence.setAt