@vcmap/core
    Preparing search index...

    Class Collection<T>

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

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index

    Accessors

    • 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

    • Type Parameters

      • T

      Parameters

      • OptionaluniqueKey: false | keyof T

        a key to maintain uniquely within the collection. passing false disables uniqueness.

      Returns Collection<T>

    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.

      Parameters

      • item: T

        the item to be inserted

      Returns number | null

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

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

      Parameters

      • value: unknown

      Returns boolean | undefined

    • Creates a Collection from an iterable, such as an Array.

      Type Parameters

      • F

      Parameters

      • iterable: Iterable<F>
      • OptionaluniqueKey: false | keyof F

        a key to maintain uniquely within the collection. passing false disables uniqueness.

      Returns Collection<F>

    Properties

    _array: T[]
    added: VcsEvent<T>

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

    removed: VcsEvent<T>

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