@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
169 lines • 4.1 kB
TypeScript
/**
* @see https://github.com/blender/blender/blob/master/source/blender/blenlib/intern/BLI_mempool.c
*/
export class BinaryElementPool {
/**
*
* @param {number} item_size in bytes
* @param {number} [initial_capacity] how many items to reverse in the newly created pool
* @param {boolean} [use_shared_buffer]
*/
constructor(item_size: number, initial_capacity?: number, use_shared_buffer?: boolean);
/**
* Unused slots
* @type {number[]}
* @private
*/
private __free;
/**
* Tracks last unallocated item in the list,
* this separate cursor is necessary to prevent re-allocation of the 'free' array
* @type {number}
* @private
*/
private __free_pointer;
/**
*
* @type {number}
* @private
*/
private __size;
/**
* Size of a single pool item in bytes
* @type {number}
* @private
*/
private __item_size;
/**
*
* @type {ArrayBuffer}
* @private
*/
private __data_buffer;
/**
*
* @type {Uint8Array}
* @private
*/
private __data_uint8;
/**
*
* @type {Uint32Array}
* @private
*/
private __data_uint32;
/**
*
* @type {Float32Array}
* @private
*/
private __data_float32;
data_view: DataView;
/**
*
* @type {number}
* @private
*/
private __capacity;
/**
*
* @param {ArrayBuffer} buffer
* @param {number} allocated_record_count
*/
fromArrayBuffer(buffer: ArrayBuffer, allocated_record_count?: number): void;
get arrayBuffer(): ArrayBuffer;
/**
* Size of a single record in bytes
* @return {number}
*/
get item_size(): number;
/**
* Returns size of used region, this includes both elements that are allocated and those that aren't
* Please note that this value does not represent number of currently active elements, if you need that - you'll need to use something else
* @return {number}
*/
get size(): number;
/**
*
* @return {number}
*/
get byteSize(): number;
/**
* Number of records that the pool can currently contain
* @return {number}
*/
get capacity(): number;
/**
*
* @return {Uint32Array}
*/
get data_uint32(): Uint32Array;
/**
*
* @return {Float32Array}
*/
get data_float32(): Float32Array;
/**
* Get rid of excess capacity
*/
trim(): void;
/**
*
* @param {number} id
* @return {number}
*/
element_address(id: number): number;
/**
* Returns word-offset of element
* Word size is 4, so this is the same as `element_address(id) / 4`
* @param {number} id
* @return {number}
*/
element_word(id: number): number;
/**
* Used alongside iterators to check if element is actually allocated or not
* @param {number} id
* @return {boolean}
*/
is_allocated(id: number): boolean;
/**
*
* @param {number} new_capacity
* @private
*/
private __set_capacity;
/**
*
* @param {number} min_capacity
* @private
*/
private __grow_capacity;
/**
*
* @param {number} capacity
*/
ensure_capacity(capacity: number): void;
/**
*
* @return {number} ID of the allocated element
*/
allocate(): number;
/**
* Allocate a continuous range of IDs in bulk
* @param {number} count
* @return {number} offset where the range starts, this is your first ID basically
*/
allocate_continuous(count: number): number;
/**
* Please note that this method does not perform any checks at all.
* You have to make sure that the item is actually unneeded and no duplicate calls are made
* @param {number} id
*/
release(id: number): void;
/**
* Removed all data from the pool
* Note that initial allocation pointer is set to 0
*/
clear(): void;
}
//# sourceMappingURL=BinaryElementPool.d.ts.map