@rimbu/proximity
Version:
Immutable ProximityMap implementation for TypeScript
33 lines • 1.23 kB
JavaScript
import { RMapBase } from '@rimbu/collection-types/map-custom';
import { ProximityMapEmpty, ProximityMapNonEmpty, } from './implementation/index.mjs';
import { ProximityMapBuilder } from './builder.mjs';
/**
* Default concrete implementation of {@link ProximityMap.Context}.<br/>
* <br/>
* It wires the configured {@link DistanceFunction} and `HashMap` context together and
* is used by the `ProximityMap` factory methods to create new instances.
*
* @typeparam UK - the upper key type bound for which the context can be used
*/
export class ProximityMapContext extends RMapBase.ContextBase {
constructor(distanceFunction, hashMapContext) {
super();
this.distanceFunction = distanceFunction;
this.hashMapContext = hashMapContext;
this.typeTag = 'ProximityMap';
this.builder = () => {
return this.createBuilder();
};
this._empty = Object.freeze(new ProximityMapEmpty(this));
}
isValidKey(key) {
return true;
}
isNonEmptyInstance(source) {
return source instanceof ProximityMapNonEmpty;
}
createBuilder(source) {
return new ProximityMapBuilder(this, source);
}
}
//# sourceMappingURL=context.mjs.map