import { ToStringable } from "../util"; /** * Store and access objects via primary key & indexes. The ObjectCache is basically a Map on steroids * that is used to cache entities of a single type and retrieve them by their primary key or * a combination of indexes. */ export declare class ObjectCache { readonly getKey: (item: V) => K; private _pkMap; private _indexes; readonly size: number; constructor(args: { getKey: (item: V) => K; indexes?: { [index: string]: (item: V) => any; }; }); all(into?: Map): Map; allAsArray(into?: V[]): V[]; byKey(key: K): V; byKeys(keys: ArrayLike, into?: Map): Map; byKeysAsArray(keys: ArrayLike): V[]; byIndex(index: string, value: any): Map; byIndexAsArray(index: string, value: any): V[]; byIndexes(indexes: { [key: string]: ToStringable; }): Map; byIndexesAsArray(indexes: { [key: string]: ToStringable; }): V[]; add(items: V[]): void; removeByIndex(index: string, value: ToStringable): void; remove(items: V[]): void; clear(): void; } export declare module ObjectCache { class Index { readonly name: string; readonly getIndexValue: (item: V) => any; readonly getKey: (item: V) => K; private _maps; private _pkMaps; constructor(args: { getIndexValue: (item: V) => any; getKey: (item: V) => K; name: string; }); /** * Returns a copy of the items stored for the given index value, * with the key being the primary key of an item. */ get(value: any): Map; getAsArray(value: any): V[]; clear(): void; clear(value: ToStringable): void; update(newItem: V): void; update(newItem: V, oldItem?: V): void; remove(item: V): void; } }