Class IndexedCollection<T>

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

Type Parameters

  • T

Hierarchy (view full)

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

  • 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

    • Optionalindex: 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 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
    • Optionalsteps: 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
    • Optionalsteps: number = 1

      an integer number to lower by

    Returns null | number

    the new index of the item

Properties

_array: T[]
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.