interface NativeIndexOptions<T, K extends PropertyKey = T & PropertyKey> {
    elements?: Iterable<T, any, any>;
    elementsEqual?: (a: T, b: T) => boolean;
    getKey?: (value: T) => K;
    keysEqual?: (a: K, b: K) => boolean;
    onDuplicateElements?: ResolveAction;
    onDuplicateKeys?: ResolveAction;
}

Type Parameters

  • T
  • K extends PropertyKey = T & PropertyKey

Properties

elements?: Iterable<T, any, any>

An iterable that will be consumed to fill the index.

elementsEqual?: (a: T, b: T) => boolean

A predicate determining when two elements are equal.

This function is only called after is has been determined that the keys are equal, so you may safely skip the equality check for the keys.

If omitted, the built-in equality function will be used.

getKey?: (value: T) => K

A function that should extract the key out of an element.

For example, dictionaries simply take the first element of a tuple array to be the key.

keysEqual?: (a: K, b: K) => boolean

A predicate for determining when two keys are equal.

Two keys may produce the same hash result, but that does not necessarily mean that they are equal. This function resolves any conflicts.

If omitted, the built-in equality function will be used.

onDuplicateElements?: ResolveAction

What to do when the the element being added already exists in the index.

This property defaults to ResolveAction.Error.

onDuplicateKeys?: ResolveAction

What to do when the key of the element being added already exists in the index.

This property defaults to ResolveAction.Error.