Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObservableUndoableList<T>

A concrete implementation of an observable undoable list.

Type parameters

  • T

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private _copyChange

_copyChange: any

Copy a change as JSON.

Private _inCompound

_inCompound: any

Private _index

_index: any

Private _isUndoable

_isUndoable: any

Private _madeCompoundChange

_madeCompoundChange: any

Private _onListChanged

_onListChanged: any

Handle a change in the list.

Private _redoChange

_redoChange: any

Redo a change event.

Private _serializer

_serializer: any

Private _stack

_stack: any

Private _undoChange

_undoChange: any

Undo a change event.

Accessors

canRedo

  • get canRedo(): boolean
  • Whether the object can redo changes.

    Returns boolean

canUndo

  • get canUndo(): boolean
  • Whether the object can undo changes.

    Returns boolean

changed

isDisposed

  • get isDisposed(): boolean
  • Test whether the list has been disposed.

    Returns boolean

length

  • get length(): number
  • The length of the list.

    Returns number

type

  • get type(): "List"
  • The type of this object.

    Returns "List"

Methods

beginCompoundOperation

  • beginCompoundOperation(isUndoAble?: boolean): void
  • Begin a compound operation.

    Parameters

    • Optional isUndoAble: boolean

      Whether the operation is undoable. The default is true.

    Returns void

clear

  • clear(): void

clearUndo

  • clearUndo(): void

dispose

  • dispose(): void

endCompoundOperation

  • endCompoundOperation(): void

get

  • get(index: number): T
  • Get the value at the specified index.

    Parameters

    • index: number

      The positive integer index of interest.

    Returns T

    The value at the specified index.

    Undefined Behavior

    An index which is non-integral or out of range.

insert

  • insert(index: number, value: T): void
  • Insert a value into the list at a specific index.

    Parameters

    • index: number

      The index at which to insert the value.

    • value: T

      The value to set at the specified index.

      Complexity

      Linear.

      Iterator Validity

      No changes.

      Notes

      The index will be clamped to the bounds of the list.

      By convention, the oldIndex is set to -2 to indicate an insert operation.

      The value -2 as oldIndex can be used to distinguish from the push method which will use a value -1.

      Undefined Behavior

      An index which is non-integral.

    Returns void

insertAll

  • insertAll(index: number, values: IterableOrArrayLike<T>): void
  • Insert a set of items into the list at the specified index.

    Parameters

    • index: number

      The index at which to insert the values.

    • values: IterableOrArrayLike<T>

      The values to insert at the specified index.

      Complexity.

      Linear.

      Iterator Validity

      No changes.

      Notes

      The index will be clamped to the bounds of the list. By convention, the oldIndex is set to -2 to indicate an insert operation.

      Undefined Behavior.

      An index which is non-integral.

    Returns void

iter

  • iter(): IIterator<T>

move

  • move(fromIndex: number, toIndex: number): void
  • Move a value from one index to another.

    parm

    fromIndex - The index of the element to move.

    Parameters

    • fromIndex: number
    • toIndex: number

      The index to move the element to.

      Complexity

      Constant.

      Iterator Validity

      Iterators pointing at the lesser of the fromIndex and the toIndex and beyond are invalidated.

      Undefined Behavior

      A fromIndex or a toIndex which is non-integral.

    Returns void

push

  • push(value: T): number

pushAll

  • pushAll(values: IterableOrArrayLike<T>): number
  • Push a set of values to the back of the list.

    Parameters

    • values: IterableOrArrayLike<T>

      An iterable or array-like set of values to add.

    Returns number

    The new length of the list.

    Complexity

    Linear.

    Notes

    By convention, the oldIndex is set to -1 to indicate an push operation.

    Iterator Validity

    No changes.

redo

  • redo(): void
  • Redo an operation.

    Returns void

remove

  • remove(index: number): T
  • Remove and return the value at a specific index.

    Parameters

    • index: number

      The index of the value of interest.

    Returns T

    The value at the specified index, or undefined if the index is out of range.

    Complexity

    Constant.

    Iterator Validity

    Iterators pointing at the removed value and beyond are invalidated.

    Undefined Behavior

    An index which is non-integral.

removeRange

  • removeRange(startIndex: number, endIndex: number): number
  • Remove a range of items from the list.

    Parameters

    • startIndex: number

      The start index of the range to remove (inclusive).

    • endIndex: number

      The end index of the range to remove (exclusive).

    Returns number

    The new length of the list.

    Complexity

    Linear.

    Iterator Validity

    Iterators pointing to the first removed value and beyond are invalid.

    Undefined Behavior

    A startIndex or endIndex which is non-integral.

removeValue

  • removeValue(value: T): number
  • Remove the first occurrence of a value from the list.

    Parameters

    • value: T

      The value of interest.

    Returns number

    The index of the removed value, or -1 if the value is not contained in the list.

    Complexity

    Linear.

    Iterator Validity

    Iterators pointing at the removed value and beyond are invalidated.

set

  • set(index: number, value: T): void

undo

  • undo(): void
  • Undo an operation.

    Returns void

Generated using TypeDoc