UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

162 lines 3.68 kB
/** * Binary Heap implementation that stores uin32 ID along with a floating point score value. * Very fast and compact. * * @see BinaryHeap */ export class Uint32Heap { /** * * @param {number} [initial_capacity] Can supply initial capacity, heap will still grow when necessary. This allows to prevent needless re-allocations when max heap size is known in advance */ constructor(initial_capacity?: number); __data_buffer: ArrayBuffer; /** * Used to access stored IDs * @type {Uint32Array} * @private */ private __data_uint32; /** * Used to access stored Score values * @type {Float32Array} * @private */ private __data_float32; /** * * @type {number} * @private */ private __capacity; /** * * @type {number} * @private */ private __size; /** * * @private */ private __capacity_grow; /** * @private * @param {number} a index of an element * @param {number} b index of an element * @returns {boolean} */ private compare; /** * Swap two elements * @private * @param {number} i element index * @param {number} j element index */ private swap; /** * @private * @param {number} index */ private heap_down; /** * Bubble up given element into its correct position * @private * @param {number} index */ private heap_up; /** * * @returns {number} */ get size(): number; /** * * @returns {number} */ get capacity(): number; /** * Node with the lowest score * @returns {number} */ get top_id(): number; /** * * @returns {boolean} */ is_empty(): boolean; /** * Returns the score of the node with the lowest score * @returns {number} */ peek_score(): number; /** * Returns the ID of the node with the lowest score * @returns {number} */ peek_min(): number; /** * Removed and returns the ID of the node with the lowest score * @returns {number} */ pop_min(): number; /** * * @param {number} id * @returns {number} */ find_index_by_id(id: number): number; /** * * @param {number} id * @returns {boolean} */ contains(id: number): boolean; /** * Clear out all the data, heap will be made empty */ clear(): void; /** * * @param {number} id * @returns {boolean} */ remove(id: number): boolean; /** * * @param {number} index */ __remove_by_index(index: number): void; /** * * @param {number} id * @param {number} score */ update_score(id: number, score: number): void; /** * Update score of an element referenced directly by index, this is a fast method, but you're generally not going to know the index so in most cases it's best to use "update_score" instead * @param {number} index * @param {number} score */ __update_score_by_index(index: number, score: number): void; /** * * @param {number} id * @returns {number} */ get_score(id: number): number; /** * Insert or update an element, if the element already exists, its score will be updated. * * @param {number} id * @param {number} score */ insert_or_update(id: number, score: number): void; /** * * @param {number} id * @param {number} score */ insert(id: number, score: number): void; } //# sourceMappingURL=Uint32Heap.d.ts.map