Class IndexedCollection<T>

A generic array based collection. Implements the Symbol.iterator (e.g. [...collection])

Type Parameters

  • T

Hierarchy

Accessors

  • get previousIndexSymbol(): symbol
  • Get the symbol which is attached to an item prior to its removal. If an item is removed, the current index of the item is set on the item with this symbol.

    Returns symbol

  • get uniqueKey(): undefined | keyof T
  • The key by which to check uniqueness against. undefined if no uniqueness constraint is set.

    Returns undefined | keyof T

Constructors

Methods

  • Parameters

    • item: T
    • itemIndex: number
    • targetIndex: number

    Returns number

  • Protected

    internal remove function, to remove an item from the collection, does not raise an event.

    Parameters

    • item: T

    Returns number

    returns the index of the removed item or -1 if the item has not been found.

  • Adds an item to the collection. Can optionally be passed an index at which to insert the item.

    Parameters

    • item: T

      the item to be inserted

    • Optional index: null | number

      an optional index at which to insert the item. clipped to the last entry

    Returns null | number

    the index at which the item was inserted

  • Returns an item identified by the unique constraint key. Returns null, if there is no uniqueness constraint.

    Parameters

    • value: unknown

      the value to test against. does a shallow comparison, if the passed a non-atomic value

    Returns undefined | T

  • Returns true, if the key exists. Returns undefined, if there is no uniqueness constraint.

    Parameters

    • value: unknown

    Returns undefined | boolean

  • Returns the index of an item or -1 if it is not part of this collection

    Parameters

    • item: T

    Returns number

  • Returns the index of a key. Returns undefined, if there is no uniqueness constraint

    Parameters

    • value: unknown

    Returns undefined | number

  • Lowers an item within the array

    Parameters

    • item: T
    • Optional steps: number = 1

      an integer number to lower by

    Returns null | number

    the new index of the item

  • Moves an item to a provided index

    Parameters

    • item: T
    • targetIndex: number

    Returns null | number

    the new index of the item

  • Raises an item within the array

    Parameters

    • item: T
    • Optional steps: number = 1

      an integer number to lower by

    Returns null | number

    the new index of the item

Properties

_array: T[]
_previousIndexSymbol: symbol
added: VcsEvent<T>

Event raised if an item is added. Is passed the added item.

moved: VcsEvent<T>

Event raised if an item is relocated within the collection. Is passed the moved item.

removed: VcsEvent<T>

Event raised if an item is removed. Is passed the removed item.

Generated using TypeDoc