@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
127 lines (126 loc) • 5.67 kB
TypeScript
import { Observable, Subject } from "rxjs";
import { Consumer } from "../util/function/Consumer";
import { Predicate } from "../util/function/Predicate";
import { Collection, Element } from "./Collection";
/**
* This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.
*/
export declare abstract class AbstractCollection<T> implements Collection<T> {
readonly contentChanged$: Subject<void>;
abstract [Symbol.iterator](): IterableIterator<Element<T>>;
abstract [Symbol.toStringTag]: string;
/**
* Returns an observable object of the collection changes
*/
get contentChanged(): Observable<void>;
/**
* Returns an iterator over the elements contained in this collection
*/
get iterator(): Iterator<Element<T>>;
/**
* Returns the number of elements in this collection.
*/
get length(): number;
/**
* Returns the number of elements in this collection
*/
get size(): number;
/**
* Ensures that this collection contains the specified element.
* @param value Element whose presence in this collection is to be ensured
* @returns `this` Object reference
* @throws `IllegalArgumentException` if the argument's value is _undefined_
* @description This method was defined for JavaScript's `Set` interface compatibility.
*/
add(value: Element<T>): this;
/**
* Ensures that this collection contains the specified element
* @param value Element whose presence in this collection is to be ensured
* @returns _true_ if this collection changed as a result of the call, _false_ otherwise
*/
abstract append(value: Element<T>): boolean;
/**
* Appends all the elements in the specified collection to this collection
* @param collection Collection containing elements to be added to this collection
* @returns _true_ if this collection changed as a result of the call
*/
appendAll<E extends T>(collection: Collection<E> | Array<E>): boolean;
/**
* Removes all the elements from this collection
*/
abstract clear(): void;
/**
* Returns _true_ if this collection contains the specified element
*/
abstract contains(value: Element<T>): boolean;
/**
* Returns _true_ if this collection contains all the elements in the specified collection
* @param coll Collection to be checked for containment in this collection
* @returns _true_ if this collection contains all the elements in the specified collection
*/
containsAll<E extends T>(coll: Collection<E> | Array<T>): boolean;
/**
* Compares the specified object with this collection for equality
* @param value Object to be compared for equality with this collection
* @returns _true_ if the specified `value` is equal to this collection
*/
equals(value: any): boolean;
/**
* Returns the first element in the provided array that satisfies the provided testing function.
* If no values satisfy the testing function, _undefined_ is returned.
* @param test The testing function
* @returns The first element in the collection that satisfies the provided testing function. Otherwise, _undefined_ is returned.
*/
find(test: Predicate<Element<T>>): Element<T> | undefined;
/**
* Performs the specified action for each element in the collection
* @param action {Consumer} The action to be performed for each element
* @throws `IllegalArgumentException`, if the specified `action` is null
*/
forEach(action: Consumer<Element<T>>): void;
/**
* Returns _true_ if this collection contains no elements
*/
isEmpty(): boolean;
/**
* Removes a single instance of the specified element from this collection, if it is present
* @param value Element to be removed from this collection, if present
* @returns _true_ if an element was removed as a result of this call
*/
abstract remove(value: Element<T>): boolean;
/**
* Removes all of this collection's elements that are also contained in the specified collection
* @param collection Collection containing elements to be removed from this collection
* @returns _true_ if this collection changed as a result of the call
*/
removeAll(collection: Collection<T> | Array<T>): boolean;
/**
* Retains only the elements in this collection that are contained in the specified collection
* @param collection Collection containing elements to be retained in this collection
* @returns _true_ if this collection changed as a result of the call
*/
retainAll(collection: Collection<T> | Array<T>): boolean;
/**
* Removes all the elements of this collection that satisfy the given predicate
* @param p A predicate which returns true for elements to be removed
* @returns _true_ if any elements were removed, _false_ otherwise
*/
removeIf(p: Predicate<Element<T>>): boolean;
/**
* Returns a sequential `Observable` object with this collection as its source
* @since 0.5.0
*/
stream(): Observable<Element<T>>;
/**
* Returns an array containing all the elements in this collection
*/
abstract toArray(): Array<Element<T>>;
/**
* Returns a JSON representation of this collection
*/
toJSON(): Array<Element<T>>;
/**
* Returns a string representation of this collection
*/
toString(): string;
}