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

103 lines (102 loc) 5.39 kB
import { Compare } from "../util/function/Compare"; import { Predicate } from "../util/function/Predicate"; import { AbstractCollection } from "./AbstractCollection"; import { Element } from "./Collection"; import { LinkedListNode } from "./LinkedList"; import { List } from "./List"; /** * This class provides a skeletal implementation of the `List` interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an _array_). */ export declare abstract class AbstractList<T> extends AbstractCollection<T> implements List<T> { protected _modCount: number; /** Modification counter. Must be overridden in the subclasses that implement `subList` method */ get modCount(): number; /** * Tests whether all elements in the list pass the test implemented by the provided function * @param callbackFn The function is called * @returns {boolean} _true_ if the `callbackFn` function returns a _truthy_ value for every list element. Otherwise, _false_. */ every(callbackFn: (value: Element<T>, index: number, list: List<T>) => boolean): boolean; /** * Creates an array as a shallow copy of a portion of the current list, filtered down to just the elements from the current list that pass the test implemented by the provided function * @param predicate A predicate function, to test each element of the list. Return a value that coerces to _true_ to keep the element, or to _false_ otherwise. * @returns An array of a portion of the given list, filtered down to just the elements from the given list that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned. */ filter(predicate: Predicate<Element<T>>): Array<Element<T>>; /** * Returns the element at the specified position in this list * @param index */ abstract get(index: number): Element<T> | undefined; /** * Gets read only node's object by its index * @param index * @private */ abstract getNode(index: number): Readonly<LinkedListNode<T>> | null; /** * Gets the parent list of the current list `view` object */ getParent(): AbstractList<T> | null; /** * Gets the range of the `from` and `to` indexes related to the `view`'s parent list (if any) * @returns */ getParentRange(): [number, number]; /** * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element * @param value * @param fromIndex */ abstract indexOf(value: Element<T>, fromIndex?: number): number; /** * Inserts the specified element at the specified position in this list * @param index * @param value */ abstract insert(index: number, value: Element<T>): boolean; /** * Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element * @param value * @param fromIndex */ abstract lastIndexOf(value: Element<T>, fromIndex?: number): number; /** * Removes the element at the specified position in this list * @param index The index of the element to be removed * @returns The element previously at the specified position */ abstract removeAt(index: number): Element<T> | undefined; /** * Removes from this list all of the elements whose index is between `fromIndex`, inclusive, and `toIndex`, exclusive * @param fromIndex Index of first element to be removed * @param toIndex Index after last element to be removed * @returns _true_ if the list is changed, else _false_ */ abstract removeRange(fromIndex: number, toIndex?: number): boolean; /** * Replaces the element at the specified position in this list with the specified element * @param index Index of the element to replace * @param value Element to be stored at the specified position * @returns The element previously at the specified position */ abstract set(index: number, value: Element<T>): Element<T> | undefined; /** * Tests whether all elements in the list pass the test implemented by the provided function * @param callbackFn A function to test for each element * @returns {boolean} _true_ if the `callbackFn` function returns a _truthy_ value for at least one element in the list. Otherwise, _false_. */ some(callbackFn: (value: Element<T>, index: number, list: List<T>) => boolean): boolean; /** * Sorts this list according to the order induced by the specified `Compare` function * @param compare The `Compare` function used to compare list elements. A _undefined_ value indicates that the elements' natural ordering should be used */ sort(compare?: Compare<Element<T>>): void; /** * Returns a view of the portion of this list between the specified `fromIndex`, inclusive, and `toIndex`, exclusive. * @param fromIndex Low endpoint (inclusive) of the subList * @param toIndex High endpoint (exclusive) of the subList * @returns A view of the specified range within this list */ abstract subList(fromIndex: number, toIndex: number): List<T>; }