import { SafeInteger } from "../../numbers"; /** * Provides basic methods to compare the equality of two objects. * * @remarks * While it is theoretically possible to let a {@link !Function} implement this interface, * this can interfere with the overload resolution logic and thus not recommended. * * @see {@link HashableEqualityComparer} */ export interface EqualityComparer { /** * Compares the equality of two objects. * * @returns * * `true` if `x` is equal to `y`. * * `false` if `x` is not equal to `y`. */ equals(x: T, y: T): boolean; /** * Given an aribtrary value, checks whether the value can be compared by the current {@link EqualityComparer}. */ isSupported(value: unknown): value is T; } /** * Provides methods to compare the equality of two objects, along with a function * to hash the objects for hash map implementation. * * @remarks * Due to the limitation of current JavaScript API, there is no efficient approach to evaluate * hash code for every primitive types (e.g. `string`). This can cause significant performance penalty. * * @see {@link EqualityComparer} */ export interface HashableEqualityComparer extends EqualityComparer { /** * Compares the equality of two objects. * * @returns * * `true` if `x` is equal to `y`. * * `false` if `x` is not equal to `y`. */ equals(x: T, y: T): boolean; /** * Evaluates the hash code for the specified `value`. * * @remarks Implementations are required to ensure that if {@link equals} returns `true` for two values `x` and `y`, * then the value returned by {@link getHashCode} for `x` must equal the value returned for `y`. */ getHashCode(value: T): SafeInteger; /** * Given an aribtrary value, checks whether the value can be compared by the current {@link HashableEqualityComparer}. */ isSupported(value: unknown): value is T; } export declare const EqualsSymbol: unique symbol; export declare const GetHashCodeSymbol: unique symbol; export interface Equatable { [EqualsSymbol](other: unknown): boolean; [GetHashCodeSymbol]?(): SafeInteger; } //# sourceMappingURL=typing.d.ts.map