Options
All
  • Public
  • Public/Protected
  • All
Menu

An index that uses native JavaScript objects to efficiently store and retrieve arbitrary values.

This container only works with hashable JavaScript types, such as string or number. Types that cannot be used as the key in a plain JavaScript object will not work.

experimental

Type parameters

  • T

  • K: PropertyKey = T & PropertyKey

Hierarchy

  • NativeIndex

Implements

Index

Constructors

constructor

Properties

areKeysEqual

areKeysEqual: (a: K, b: K) => boolean

Type declaration

    • (a: K, b: K): boolean
    • Parameters

      • a: K
      • b: K

      Returns boolean

getKey

getKey: (element: T) => K

Type declaration

    • (element: T): K
    • Parameters

      • element: T

      Returns K

isEqual

isEqual: (a: T, b: T) => boolean

Type declaration

    • (a: T, b: T): boolean
    • Parameters

      • a: T
      • b: T

      Returns boolean

onDuplicateElements

onDuplicateElements: ResolveAction

onDuplicateKeys

onDuplicateKeys: ResolveAction

Accessors

size

  • get 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.

    Returns number

Methods

[Symbol.iterator]

  • [Symbol.iterator](): Generator<any, void, unknown>
  • 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 Generator<any, void, unknown>

add

clear

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

    Returns void

clone

cursors

  • cursors(): Generator<NativeIndexCursor<T, K>, void, unknown>

delete

  • delete(element: T): boolean

deleteAll

  • deleteAll(element: T): number

deleteAt

  • deleteAt(position: NativeIndexCursor<T, K>): void

deleteKey

  • deleteKey(key: K): number

equalKeys

  • equalKeys(key: K): Range<T>

findKey

  • findKey(key: K): null | NativeIndexCursor<T, K>

has

  • has(element: T): boolean

hasKey

  • hasKey(key: K): boolean

toRange

Legend

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

Generated using TypeDoc