@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
75 lines (74 loc) • 4.24 kB
TypeScript
import { Collection, Element } from "../collections/Collection";
import { ImmutableList, List } from "../collections/List";
import { Comparator } from "./Comparator";
import { ImmutableSet } from "../collections/AbstractSet";
import { ImmutableMap } from "../collections/AbstractMap";
/**
* This class consists exclusively of static methods that operate on or return collections.
*/
export declare class Collections {
/**
* Adds all of the specified elements to the specified collection
* @param c Collection object
* @param elements Elements to add to the collection `c`
* @returns _true_ if the collection changed as a result of this call, or _false_ otherwise
*/
static addAll<T>(c: Collection<T>, ...elements: Element<T>[]): boolean;
/**
* Returns the number of elements in the specified collection equal to the specified object
* @param c The collection in which to determine the frequency of o
* @param o The object whose frequency is to be determined
* @returns The number of elements in c equal to o
*/
static frequency<T>(c: Collection<T>, o: Element<T>): number;
/**
* Returns the maximum element of the given collection, according to the _natural ordering_ of its elements or to the order induced by the specified comparator
* @param c The collection whose maximum element is to be determined
* @param comparator The comparator with which to determine the maximum element. An _undefined_ value indicates that the elements' natural ordering should be used.
* @returns The maximum element of the given collection, according to the specified comparator. Returns _undefined_ if the collection `c` is empty.
*/
static max<T>(c: Collection<T>, comparator?: Comparator<T>): Element<T> | undefined;
/**
* Returns the minimum element of the given collection, according to the _natural ordering_ of its elements or to the order induced by the specified comparator
* @param c The collection whose minimum element is to be determined
* @param comparator The comparator with which to determine the minimum element. An _undefined_ value indicates that the elements' natural ordering should be used.
* @returns The minimum element of the given collection, according to the specified comparator. Returns _undefined_ if the collection `c` is empty.
*/
static min<T>(c: Collection<T>, comparator?: Comparator<T>): Element<T> | undefined;
/**
* Replaces all occurrences of one specified value in a list with another
* @param list The list in which replacement is to occur
* @param oldVal The old value to be replaced
* @param newVal The new value with which `oldVal` is to be replaced
* @returns _true_ if the `list` was changed, _false_ otherwise
*/
static replaceAll<T>(list: List<T>, oldVal: Element<T>, newVal: Element<T>): boolean;
/**
* Reverses the order of the elements in the specified list
* @param list The list whose elements are to be reversed
* @returns The list argument itself
*/
static reverse<T>(list: List<T>): List<T>;
/**
* Returns an immutable set containing only the specified object
* @param object The sole object to be stored in the returned set
* @returns An immutable set containing only the specified object
* @since 0.5.0
*/
static singleton<T = unknown>(object: T): ImmutableSet<T>;
/**
* Returns an immutable list containing only the specified object.
* @param object The sole object to be stored in the returned list
* @returns An immutable list containing only the specified object
* @since 0.5.0
*/
static singletonList<T = unknown>(object: T): ImmutableList<T>;
/**
* Returns an _immutable_ map, mapping only the specified key to the specified value.
* @param key The sole key to be stored in the returned map
* @param value The value to which the returned map maps key
* @returns An immutable map containing only the specified key-value mapping
* @since 0.5.0
*/
static singletonMap<K, V>(key: K, value: V): ImmutableMap<K, V>;
}