UNPKG

delphirtl

Version:
235 lines (234 loc) 4.73 kB
/** * A first in, first out class * @category Collections */ declare class Queue<T> { #private; /** * * @param val Puts the given value into the class */ push(val: T): void; /** * * @returns The first value in the store */ pop(): T | undefined; /** * * @returns The first value in the store */ next(): T | undefined; /** * The number of values in the store * * @readonly * @type {number} */ get length(): number; } /** * A last in, first out class * * @class Stack * @typedef {Stack} * @template T * @category Collections */ declare class Stack<T> { #private; /** * * @param v Puts the given value into the store */ push(v: T): void; /** * * @returns The last value that was pushed into the store */ pop(): T | undefined; /** * The number of items in the store * * @readonly * @type {number} */ get length(): number; } /** * Dictionary * * @class Dictionary * @typedef {Dictionary} * @template K * @template V * @extends {Map<K, V>} * @category Collections */ declare class Dictionary<K, V> extends Map<K, V> { /** * Sets the specified value for the given key. * @param key * @param value */ AddOrSetValue(key: K, value: V): void; /** * Sets the specified value for the given key. * @param key * @param value */ Add(key: K, value: V): void; /** * Clears the dictionary of all data */ Clear(): void; /** * Gets the number of keys and values stored. * * @public * @readonly * @type {number} */ get Count(): number; /** * Gets the number of keys and values stored. * * @public * @readonly * @type {number} */ get count(): number; /** * Gets the keys and values stored in the Dictionary * * @public * @readonly * @type {{ [key: string]: V }} */ get Items(): { [key: string]: V; }; /** * Gets all items * * @public * @readonly * @type {{ [key: string]: V }} */ get items(): { [key: string]: V; }; /** * Returns a boolean, which, if true, means value has valid information. * * @param {K} key * @returns {{ * found: boolean, * value: V | undefined * }} */ TryGetValue(key: K): { found: boolean; value: V | undefined; }; /** * Returns true if the dictionary has the specified key, false if not. * * @param {K} key * @returns {boolean} */ Contains(key: K): boolean; /** * Returns true if the dictionary contains the given value. * * @param {V} value * @returns {boolean} */ ContainsValue(value: V): boolean; /** * Adds the given key and value * * @param {K} key * @param {V} value * @returns {boolean} */ TryAdd(key: K, value: V): boolean; /** * Removes the given key and its value. * * @param {K} key */ Remove(key: K): void; } export type PTreeNode<T> = TreeNode<T> | null; /** * TreeNode * * @class TreeNode * @typedef {TreeNode} * @template T * @category Collections */ declare class TreeNode<T> { left: PTreeNode<T>; right: PTreeNode<T>; data: T; constructor(value: T); static createTree<T>(nodeValues: Iterable<T>): TreeNode<T>; /** * Returns the height of the tree. Call only when this is the root. * * @public * @readonly * @type {number} height of the tree */ get height(): number; } declare const SEmptyIterables = "Iterable do not have any elements!"; /** * List * * @class List * @typedef {List} * @template T * @category Collections */ declare class List<T> { find(callback: T): boolean; private items; constructor(); /** * * @returns Size of the List */ size(): number; /** * Returns the length of this list * * @public * @readonly * @type {number} */ get length(): number; /** * Adds a value to the list * @param value The value to add to the list */ add(value: T): void; indexOf(value: T): number; get(index: number): T; /** * Delete a specified value * * @type {*} */ delete(value: T): boolean; /** * Removes the specified value * @param value * @returns */ remove(value: T): boolean; [Symbol.iterator](): Iterator<T>; } export { Queue, Dictionary, TreeNode as Tree, TreeNode, Stack, List, SEmptyIterables };