Options
All
  • Public
  • Public/Protected
  • All
Menu

Base interface for Dict and MultiDict.

Type parameters

  • K

  • V

Hierarchy

Index

Properties

Readonly size

size: number

Count the amount of elements in the collection.

⚠️ In most cases, this should be an O(1) operation. However, there are cases where this can be an O(n) operation. Therefore, it is recommended to always cache the result in a local variable.

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<[K, V]>
  • Returns an object which is able to sift through the values in this collection.

    The order by which the elements are traversed depends on the kind of collection. For unordered collections, the iteration order is unspecified and may even differ between two iterations on the same collection.

    Returns IterableIterator<[K, V]>

add

  • add(element: [K, V], hint?: any): AddResult<[K, V]>
  • Add an element to the collection. If the element already exists, update its value.

    The location where the element is placed depends on the collection type, and in the generic case there is no guarantee on the location where it is inserted.

    This method returns a pair with the first element indicating whether the element was added, while the second element refers to the actual location of the element.

    Parameters

    • element: [K, V]
    • Optional hint: any

      A transparent object obtained by getAddHint.

    Returns AddResult<[K, V]>

clear

  • clear(): void
  • Remove all elements from this collection, effectively setting the collection to the empty collection.

    Returns void

clone

delete

  • delete(element: [K, V]): boolean
  • Remove an element from the collection. If multiple elements are matched, the collection picks one of them.

    Parameters

    • element: [K, V]

    Returns boolean

    true if the element was found, false otherwise.

deleteAll

  • deleteAll(element: [K, V]): number
  • Remove an element from the collection. If multiple elements are matched, the collection removes all of them.

    Parameters

    • element: [K, V]

    Returns number

    The amount of elements that was removed.

deleteAt

  • deleteAt(position: Cursor<[K, V]>): void
  • Remove the element pointed to by the iterator result from this collection.

    Parameters

    Returns void

deleteKey

  • deleteKey(key: K): number
  • Delete a pair from the underlying collection that has the given key as key.

    Returns the amount of items that have been deleted.

    Parameters

    • key: K

    Returns number

emplace

  • emplace(key: K, value: V): [boolean, Cursor<[K, V]>]
  • Creates a new pair and inserts it in the underlying collection.

    Parameters

    • key: K
    • value: V

    Returns [boolean, Cursor<[K, V]>]

equalKeys

  • equalKeys(key: K): Range<[K, V]>

findKey

  • findKey(key: K): null | Cursor<[K, V]>
  • Similar to Dict.getValue, except that it returns the pair that was inserted in the collection.

    Parameters

    • key: K

    Returns null | Cursor<[K, V]>

Optional getAddHint

  • getAddHint(element: [K, V]): any
  • Returns a transparent object that can be used as an argument to add to speed up things. Generally, you don't have to use this method.

    Parameters

    • element: [K, V]

    Returns any

has

  • has(element: [K, V]): boolean
  • Checks if the collection holds the given element.

    Parameters

    • element: [K, V]

      The element to check membership of.

    Returns boolean

    True if the collections holds the given element, false otherwise.

hasKey

  • hasKey(key: K): boolean
  • Checks whether there a pair in this collection that has the given key.

    Parameters

    • key: K

    Returns boolean

Optional iterator

  • iterator(): Iterator<[K, V], any, undefined>

toRange

  • toRange(): Range<[K, V]>

Legend

  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Inherited property
  • Inherited method

Generated using TypeDoc