UNPKG

@cute-dw/core

Version:

This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need

40 lines (39 loc) 2.83 kB
import { Compare } from "../util/function/Compare"; import { Predicate } from "../util/function/Predicate"; import { Collection, Element, ImmutableCollection } from "./Collection"; /** * An ordered _immutable_ collection. This interface places additional stipulations, beyond those specified in the inherited * `ImmutableCollection` interface. */ export interface ImmutableList<T> extends ImmutableCollection<T> { /** Tests whether all elements in the list pass the test implemented by the provided function */ every(callbackFn: (value: Element<T>, index: number, list: List<T>) => boolean): boolean; /** Creates an array as a shallow copy of a portion of a given list, filtered down to just the elements from the given list that pass the test implemented by the provided function */ filter(predicate: Predicate<Element<T>>): Array<Element<T>>; /** Returns the element at the specified position in this list */ get(index: number): Element<T> | undefined; /** Gets the parent list of the current list `view` object */ getParent(): List<T> | null; /** Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element */ indexOf(value: Element<T>, fromIndex?: number): number; /** Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element */ lastIndexOf(value: Element<T>, fromIndex?: number): number; /** Tests whether at least one element in the list passes the test implemented by the provided function */ some(callbackFn: (value: Element<T>, index: number, list: List<T>) => boolean): boolean; /** Returns a _view_ of the portion of this list between the specified `fromIndex`, inclusive, and `toIndex`, exclusive */ subList(fromIndex: number, toIndex: number): List<T>; } /** * An ordered _mutable_ collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. * The user can access elements by their integer index (position in the list), and search for elements in the list. */ export interface List<T> extends ImmutableList<T>, Collection<T> { /** Inserts the specified element at the specified position in this list */ insert(index: number, value: Element<T>): boolean; /** Removes the element at the specified position in this list */ removeAt(index: number): Element<T> | undefined; /** Replaces the element at the specified position in this list with the specified element */ set(index: number, value: Element<T>): Element<T> | undefined; /** Sorts this list according to the order induced by the specified `Compare` function */ sort(compare?: Compare<Element<T>>): void; }