UNPKG

graph-builder

Version:

A graph builder library for modeling abstract graph structures.

60 lines (59 loc) 1.94 kB
import { Comparator } from "../collect/Comparator"; import { Comparable } from "../collect/Comparable"; /** * The type of ordering that this object specifies. * * <ul> * <li>UNORDERED: no order is guaranteed. * <li>INSERTION: insertion ordering is guaranteed. * <li>SORTED: ordering according to a supplied comparator is guaranteed. * </ul> */ export declare enum Type { UNORDERED = 0, INSERTION = 1, SORTED = 2 } /** * Used to represent the order of elements in a data structure that supports different options for * iteration order guarantees. * * @remarks * * Example usage: * * ```typescript * const graph: MutableGraph<number> = * GraphBuilder.directed().nodeOrder(ElementOrder.natural<number>()).build(); * } * ``` * * @public */ export declare class ElementOrder<T> { readonly type: Type; private readonly comparator?; constructor(type: Type, comparator?: Comparator<T> | undefined); /** Returns an instance which specifies that no ordering is guaranteed. */ static unordered<S>(): ElementOrder<S>; /** Returns an instance which specifies that insertion ordering is guaranteed. */ static insertion<S>(): ElementOrder<S>; /** * Returns an instance which specifies that the natural ordering of the elements is guaranteed. */ static natural<S extends Comparable<S>>(): ElementOrder<S>; /** * Returns an instance which specifies that the ordering of the elements is guaranteed to be * determined by `comparator`. */ static sorted<S>(comparator: Comparator<S>): ElementOrder<S>; /** * Returns the {@link Comparator} used. * * Throws an error if comparator is not defined */ getComparator(): Comparator<T>; equals(obj?: object): boolean; /** Returns an empty mutable map whose keys will respect this {@link ElementOrder}. */ createMap<K extends T, V>(expectedSize: number): Map<K, V>; }