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.
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IndexCursorSequence<
T>(host):IndexCursorSequence<T>
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:47
Parameters
Section titled “Parameters”Returns
Section titled “Returns”IndexCursorSequence<T>
Methods
Section titled “Methods”begin()
Section titled “begin()”begin():
IRandomAccessCursor<T>
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:49
The first element; invalid when empty.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.begin
cursorAt()
Section titled “cursorAt()”cursorAt(
index):IRandomAccessCursor<T>
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:57
O(1) for random-access backings, O(n) otherwise.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.cursorAt
end():
IRandomAccessCursor<T>
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:53
The past-the-end position, used to append.
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.end
insertAfter()
Section titled “insertAfter()”insertAfter(
cursor,item):void
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:64
Inserts an item after cursor. O(1).
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position after which to insert.
T
The item to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.insertAfter
insertAllAfter()
Section titled “insertAllAfter()”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.
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position after which to insert.
readonly T[]
The items to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.insertAllAfter
insertAllBefore()
Section titled “insertAllBefore()”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.
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position before which to insert.
readonly T[]
The items to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.insertAllBefore
insertBefore()
Section titled “insertBefore()”insertBefore(
cursor,item):void
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:78
Inserts an item before cursor. O(1).
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position before which to insert.
T
The item to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.insertBefore
notifyClear()
Section titled “notifyClear()”notifyClear():
void
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:147
Called by the host after every clear.
Returns
Section titled “Returns”void
notifyMutation()
Section titled “notifyMutation()”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.
Parameters
Section titled “Parameters”number
deleteCount
Section titled “deleteCount”number
insertCount
Section titled “insertCount”number
Returns
Section titled “Returns”void
removeAfter()
Section titled “removeAfter()”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.
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position before the element to remove.
Returns
Section titled “Returns”T | undefined
The removed element, or undefined if there was none.
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.removeAfter
removeAt()
Section titled “removeAt()”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.
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position to remove.
Returns
Section titled “Returns”T | undefined
The removed element, or undefined if cursor was not valid.
Implementation of
Section titled “Implementation of”IBidirectionalCursorSequence.removeAt
setAt()
Section titled “setAt()”setAt(
cursor,item):void
Defined in: packages/data/src/cursor/index-cursor-sequence.ts:107
Replaces the element at cursor.
Parameters
Section titled “Parameters”cursor
Section titled “cursor”The position to replace.
T
The new item.
Returns
Section titled “Returns”void