UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

45 lines (44 loc) 1.77 kB
/** * When to fill the value -&gt; key direction of a {@link BiMap}. * * - `lazy` (default) fills it on the first reverse lookup and maintains it from then on, so a map nobody asks in * reverse never pays a write per entry. * - `eager` fills it from the start, for a map written once and then asked in reverse from a hot path. * * Both answer {@link BiMap#getKey|getKey} and {@link BiMap#hasValue|hasValue} the same, they differ only in when * the work happens. */ export type BiMapReverse = 'lazy' | 'eager'; /** * Implementation of a bidirectional map * * All map-related functions are based on the normal Key -&gt; Value map */ export declare class BiMap<K, V extends object> implements Map<K, V> { readonly [Symbol.toStringTag]: string; size: number; private readonly k2v; private v2k; private readonly eager; /** * @param base - the entries to fill the map with * @param reverse - when to fill the value -&gt; key direction; see {@link BiMapReverse} */ constructor(base?: Iterable<[K, V]>, reverse?: BiMapReverse); [Symbol.iterator](): MapIterator<[K, V]>; clear(): void; delete(key: K): boolean; entries(): MapIterator<[K, V]>; forEach(callbackFunction: (value: V, key: K, map: Map<K, V>) => void): void; get(key: K): V | undefined; getKey(value: V): K | undefined; has(key: K): boolean; hasValue(value: V): boolean; keys(): MapIterator<K>; set(key: K, value: V): this; /** the reverse direction can no longer be maintained in place, so re-derive it (at once if eager) */ private staleReverse; values(): MapIterator<V>; /** the value -&gt; key direction, filled from the entries already present if this is its first use */ private reverse; }