@vcmap/core
    Preparing search index...

    Class IndexedCollection<T>

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

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    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(): keyof T | undefined

      The key by which to check uniqueness against. undefined if no uniqueness constraint is set.

      Returns keyof T | undefined

    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

      • Optionalindex: number | null

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

      Returns number | null

      the index at which the item was inserted

    • Parameters

      • predicate: (value: T, index: number, obj: T[]) => boolean

      Returns number

    • 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 T | undefined

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

      Parameters

      • value: unknown

      Returns boolean | undefined

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

      Parameters

      • value: unknown

      Returns number | undefined

    • Lowers an item within the array

      Parameters

      • item: T
      • Optionalsteps: number = 1

        an integer number to lower by

      Returns number | null

      the new index of the item

    • Moves an item to a provided index

      Parameters

      • item: T
      • targetIndex: number

      Returns number | null

      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 number | null

      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.