import { type BiMultiMapBase, BiMultiMapContext, type BiMultiMapGeneric, } from '@rimbu/bimultimap/custom'; import type { MultiMap } from '@rimbu/multimap'; import type { Streamable } from '@rimbu/stream'; /** * A type-invariant immutable bi-directional MultiMap where keys and values have a * many-to-many mapping. * See the [BiMultiMap documentation](https://rimbu.org/docs/collections/bimultimap) and the [BiMultiMap API documentation](https://rimbu.org/api/rimbu/bimultimap/BiMultiMap/interface) * @typeparam K - the key type * @typeparam V - the value type */ export interface BiMultiMap extends BiMultiMapBase {} export namespace BiMultiMap { /** * A non-empty type-invariant immutable bi-directional MultiMap where keys and values have a * many-to-many mapping. * See the [BiMultiMap documentation](https://rimbu.org/docs/collections/bimultimap) and the [BiMultiMap API documentation](https://rimbu.org/api/rimbu/bimultimap/BiMultiMap/interface) * @typeparam K - the key type * @typeparam V - the value type */ export interface NonEmpty extends BiMultiMapBase.NonEmpty, Omit, keyof BiMultiMapBase.NonEmpty>, Streamable.NonEmpty<[K, V]> {} /** * The BiMultiMap's Context instance that serves as a factory for all related immutable instances and builders. * @typeparam UK - the upper key type for which the context can create instances * @typeparam UV - the upper value type for which the context can create instances */ export interface Context extends BiMultiMapBase.Context {} /** * A mutable `BiMultiMap` builder used to efficiently create new immutable instances. * See the [BiMultiMap documentation](https://rimbu.org/docs/collections/bimultimap) and the [BiMultiMap.Builder API documentation](https://rimbu.org/api/rimbu/bimultimap/BiMultiMap/Builder/interface) * @typeparam K - the key type * @typeparam V - the value type */ export interface Builder extends BiMultiMapBase.Builder {} /** * Utility interface that provides higher-kinded types for this collection. */ export interface Types extends BiMultiMapBase.Types { readonly context: BiMultiMap.Context; readonly normal: BiMultiMap; readonly nonEmpty: BiMultiMap.NonEmpty; readonly builder: BiMultiMap.Builder; } } export const BiMultiMap: BiMultiMapGeneric.Creators = Object.freeze({ createContext(options: { keyValueMultiMapContext: MultiMap.Context; valueKeyMultiMapContext: MultiMap.Context; }): BiMultiMap.Context { return Object.freeze( new BiMultiMapContext( 'BiMultiMap', options.keyValueMultiMapContext, options.valueKeyMultiMapContext ) ); }, });