import type { Func } from "../../../../types/concepts"; export interface IContainer extends Iterable { /** * The number of elements in the container. */ readonly size: number; [Symbol.iterator](): Iterator; } export interface ILinearContainer extends IContainer { get(index: number): T | undefined; set(index: number, value: T): void; } export interface ICollection extends IContainer { /** * Add a value to the collection. * @param value The value to add to the container * @returns `true` if added, `false` otherwise. */ add(value: T): boolean; /** * Remove a value from the collection. * @param value The value to add to the container * @returns `true` if removed, `false` otherwise. */ remove(value: T): boolean; /** * Test if a value exists in the collection. * @param value The value to add to the container * @returns `true` if exists, `false` otherwise */ has(value: T): boolean; } export interface ILinkedNode { readonly value: T; readonly next: ILinkedNode | undefined; readonly previous: ILinkedNode | undefined; } export interface ILinkedList extends IContainer { readonly head: ILinkedNode | undefined; readonly tail: ILinkedNode | undefined; } export interface IStack extends IContainer { push(value: T): void; pop(): T; readonly top: T; } export interface IQueue extends IContainer { enqueue(value: T): void; dequeue(): T; readonly front: T; readonly back: T; } export interface CacheMap extends Pick, "get" | "has"> { set: (key: K, value: V) => this; } export type Comparator = Func<[a: T, b: T], number>;