UNPKG

typescript-ds-lib

Version:

A collection of TypeScript data structure implementations

31 lines (30 loc) 812 B
import { BaseCollection } from './base-collection'; import { Comparator } from '../types'; export interface Set<T> { insert(element: T): void; insertList(elements: T[]): void; remove(element: T): void; find(element: T): boolean; has(element: T): boolean; forEach(callback: (element: T) => void): void; } export declare class Set<T> extends BaseCollection<T> implements Set<T> { private tree; constructor(comparator?: Comparator<T>); /** * Removes all elements from the set. */ clear(): void; /** * Returns true if the set contains no elements. */ isEmpty(): boolean; /** * Returns the number of elements in the set. */ size(): number; /** * Checks if two sets are equal. */ equals(other: Set<T>): boolean; }