@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
89 lines (88 loc) • 5.03 kB
TypeScript
import { Observable } from 'rxjs';
import { Element } from './Collection';
import { Dictionary } from './Dictionary';
export type Entry<K, V> = {
key: K;
value: Element<V>;
};
/**
* The root immutable `Map` interface
*/
export interface ImmutableMap<K, V> extends ReadonlyMap<K, V> {
/** Returns an observable object to look after the changes in this collection */
get contentChanged(): Observable<void>;
/** Returns the number of key-value mappings in this map */
get size(): number;
/** +Returns true if this map contains a mapping for the specified `key` */
containsKey(key: K): boolean;
/** +Returns _true_ if this map maps one or more keys to the specified `value` */
containsValue(value: V): boolean;
/** Returns an iterable iterator of the key/value pair contained in this map */
entries(): IterableIterator<[K, V]>;
/** Calls the callback function `callbackfn` for each key/value entry in the map */
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
/** Returns the value to which the specified `key` is mapped, or `undefined` if this map contains no mapping for the key */
get(key: K): V | undefined;
/** Returns true if this map contains a mapping for the specified `key` */
has(key: K): boolean;
/** +Returns _true_ if this map contains no key-value mappings */
isEmpty(): boolean;
/** Returns an iterable iterator of the keys contained in this map */
keys(): IterableIterator<K>;
/** +Gets the keys of this tree as a `Set` collection */
keySet(): Set<K>;
toString(): string;
/** Returns an iterable iterator of the values contained in this map */
values(): IterableIterator<V>;
/** Returns an iterable iterator of the key/value pair contained in this map */
[](): IterableIterator<[K, V]>;
/** Returns the name (classname) of the map */
[]: string;
}
/**
* This class provides a skeletal implementation of the mutable `Map` interface, to minimize the effort required to implement this interface.
*/
export declare abstract class AbstractMap<K, V> implements ImmutableMap<K, V>, Map<K, V> {
/** Returns an observable object to look after the changes in this collection */
abstract get contentChanged(): Observable<void>;
/** Returns the number of key-value mappings in this map */
abstract get size(): number;
/** Removes all of the mappings from this map */
abstract clear(): void;
/** +Returns true if this map contains a mapping for the specified `key` */
abstract containsKey(key: K): boolean;
/** +Returns _true_ if this map maps one or more keys to the specified `value` */
abstract containsValue(value: V): boolean;
/** Removes the mapping for a key from this map if it is present */
delete(key: K): boolean;
/** Returns an iterable iterator of the key/value pair contained in this map */
abstract entries(): IterableIterator<[K, V]>;
/** Calls the callback function `callbackfn` for each key/value entry in the map */
abstract forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
/** Returns the value to which the specified `key` is mapped, or `undefined` if this map contains no mapping for the key */
abstract get(key: K): V | undefined;
/** Returns true if this map contains a mapping for the specified `key` */
abstract has(key: K): boolean;
/** +Returns _true_ if this map contains no key-value mappings */
isEmpty(): boolean;
/** Returns an iterable iterator of the keys contained in this map */
abstract keys(): IterableIterator<K>;
/** +Gets the keys of this tree as a `Set` collection */
abstract keySet(): Set<K>;
/** +Associates the specified `value` with the specified `key` in this map and returns the previous value of the key if it was mapped */
abstract put(key: K, value: V): Element<V> | undefined;
/** +Copies all of the mappings from the specified map to this map */
abstract putAll<Key extends K, Value extends V>(map: Dictionary<Key, Value> | Map<Key, Value>): void;
/** +Removes the mapping for a `key` from this map and returns the previous value of the mapping if it is present */
abstract remove(key: K): Element<V> | undefined;
/** Associates the specified `value` with the specified `key` in this map and returns the map object reference */
abstract set(key: K, value: V): this;
/** +Gets the string representation of the map */
abstract toString(): string;
/** Returns an iterable iterator of the values contained in this map */
abstract values(): IterableIterator<V>;
/** Returns an iterable iterator of the key/value pair contained in this map */
abstract [Symbol.iterator](): IterableIterator<[K, V]>;
/** Returns the name (classname) of the map */
abstract [Symbol.toStringTag]: string;
}