UNPKG

@d1g1tal/collections

Version:
72 lines (70 loc) 1.81 kB
type NodeOptions<E> = Partial<Omit<Node<E>, 'value'>> & { value: E; }; /** * JavaScript implementation of a Node that can be used in a linked list. */ declare class Node<E> { protected $previous: Node<E> | null; protected $next: Node<E> | null; protected $value: E; /** * Creates a new node with the given value. * * @param {Node<E>} options The options for the node, or the node to copy. * @param {Node<E>} [options.previous] The previous node. * @param {Node<E>} [options.next] The next node. * @param {E} options.value The value to be assigned to the node. */ constructor({ previous, next, value }: NodeOptions<E>); /** * Gets the previous node. * * @returns {Node<E> | null} The previous node. */ get previous(): Node<E> | null; /** * Sets the previous node. * * @param {Node<E> | null} previous The previous node. */ set previous(previous: Node<E> | null); /** * Gets the next node. * * @returns {Node<E> | null} The next node. */ get next(): Node<E> | null; /** * Sets the next node. * * @param {Node<E> | null} next The next node. */ set next(next: Node<E> | null); /** * Gets the value of the node. * * @returns {E} The value of the node. */ get value(): E; /** * Sets the value of the node. * * @param {E} value The value of the node. */ set value(value: E); /** * Unlinks this node from the list. * * @returns {void} */ unlink(): void; /** * Returns a string description of the class. * * @override * @returns {string} A string description of the class. */ get [Symbol.toStringTag](): string; } export { Node };