@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
35 lines (34 loc) • 1.37 kB
TypeScript
/**
* A default map allows for a generator producing values automatically if you want to add something to a map that does not have a value associated with a given key.
* This does not implement the default map interface as return types (and some future methods may) change
*/
export declare class DefaultMap<K, V = K> {
/** the internal map the default map wraps around */
private readonly internal;
/** generator function to produce a default value for a given key */
private readonly generator;
/**
* @param generator - the generator to produce a default value for a given key
* @param map - the initial map to start with
*/
constructor(generator: (k: K) => V, map?: Map<K, V>);
/**
* Sets a value for a given key.
* As you provide value, this does not invoke the generator!
*/
set(k: K, v: V): this;
/**
* Return a value for the given key, if the key does not exist within the default map,
* this will invoke the generator and assign the produced value.
*/
get(k: K): V;
/**
* Iterates over all entries that have been set (explicitly or by the generator)
*/
entries(): MapIterator<[K, V]>;
/** returns only the keys really stored in the map */
keys(): MapIterator<K>;
values(): MapIterator<V>;
delete(k: K): boolean;
size(): number;
}