UNPKG

standard-data-structures

Version:

A collection of standard data-structures for node and browser

55 lines (54 loc) 1.37 kB
import { ICollection } from '../internals/iCollection'; /** * An immutable singly linked list data-structure */ export declare abstract class List<A> implements ICollection<A> { /** * Converts a list into an Array */ readonly asArray: A[]; /** * Creates an empty [[List]] */ static empty<A>(): List<A>; /** * Creates a new [[List]] with the provided elements. */ static of<A>(...element: A[]): List<A>; /** * Returns the head of a [[List]] */ abstract readonly head: A; /** * Returns true if the list is empty */ abstract readonly isEmpty: boolean; /** * Returns the complete list without the first element */ abstract readonly tail: List<A>; /** * Refer [[ICollection.filter]] */ filter(F: (A: A) => boolean): List<A>; /** * Reverses the List. */ readonly reverse: List<A>; /** * Transforms the [[List]] into a value */ fold<B>(seed: B, ab: (a: A, b: B) => B): B; /** * Transforms the values of the linked list */ map<B>(ab: (a: A) => B): List<B>; /** * Creates a new [[List]] with the provided element in its head. */ prepend(element: A): List<A>; /** * Folds the original list into a value of the same type */ reduce(ab: (a: A, b: A) => A): A; }