deep-equality-data-structures
Version:
Javascript data structures (e.g., Map, Set) that support deep object equality
84 lines (83 loc) • 2.32 kB
TypeScript
import { Comparable } from './comparable';
import { Options } from './options';
/**
* A Set implementation that supports deep equality for values.
*/
export declare class DeepSet<V, TxV = V> extends Set<V> implements Comparable<DeepSet<V, TxV>> {
private options?;
private readonly map;
/**
* @param values optional list of values to initialize the set
* @param options configuration options
*/
constructor(values?: readonly V[] | null, options?: Options<V, null, TxV, null> | undefined);
/**
* Getter for number of elements in the set.
* @inheritdoc
*/
get size(): number;
/**
* Returns true if the given value is present in the set.
* @inheritdoc
*/
has(val: V): boolean;
/**
* @inheritdoc
*/
add(val: V): this;
/**
* @inheritdoc
*/
delete(val: V): boolean;
/**
* Clear all values from the map.
* @inheritdoc
*/
clear(): void;
/**
* @inheritdoc
*/
forEach(callbackfn: (val: V, val2: V, set: Set<V>) => void): void;
/**
* @inheritdoc
*/
[Symbol.iterator](): IterableIterator<V>;
/**
* @inheritdoc
*/
entries(): IterableIterator<[V, V]>;
/**
* @inheritdoc
*/
keys(): IterableIterator<V>;
/**
* @inheritdoc
*/
values(): IterableIterator<V>;
/**
* @param other the set to compare against
* @returns true if the values of `other` are the same as this set
*/
equals(other: this): boolean;
/**
* @param other the set to compare against
* @returns true if the values of `other` are all contained in this set
*/
contains(other: this): boolean;
/**
* @param other the set to compare against
* @returns a new set whose values are the union of `this` and `other`.
*/
union(other: this): DeepSet<V, TxV>;
/**
* @param other the set to compare against
* @returns a new set containing all values in `this` that are also in `other`.
*/
intersection(other: this): DeepSet<V, TxV>;
/**
* @param other the set to compare against
* @returns a new set containing all values in `this` that are not also in `other`.
*/
difference(other: this): DeepSet<V, TxV>;
private getSetFromMapKeys;
}