@casual-simulation/aux-common
Version:
Common library for AUX projects
31 lines • 1.33 kB
TypeScript
import type { Bot } from './Bot';
import type { BotObjectsContext } from './BotObjectsContext';
/**
* Creates a lookup table for the given tags.
* This makes repeated queries against the same tags much quicker.
* @param calc The calculation context.
* @param tags The tags that the lookup table should be built from.
* @param defaults The default values that should be used for tags that are missing.
*/
export declare function buildLookupTable(calc: BotObjectsContext, tags: string[], defaults?: any[]): BotLookupTable;
/**
* Defines a lookup table for a group of bots.
* Lookup tables help performance by calculating lists of bots which have the same values for
* a given set of tags. This makes subsequent queries for the same set of tags effectively a O(1) operation instead of a O(N) operation.
*
* Building the table is O(N) because all the bots need to be scanned to build the table.
*/
export declare class BotLookupTable {
private _map;
private _tags;
constructor(calc: BotObjectsContext, tags: string[], defaults: any[]);
/**
* Queries the lookup table.
* @param values The values to query.
*/
query(values: any[]): Bot[];
toString(): string;
private _saveBot;
}
export declare function valuesToKey(values: any[]): string;
//# sourceMappingURL=BotLookupTable.d.ts.map