2021-04-16 17:10:15 +02:00
|
|
|
|
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Pool](pool.md)
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
# Class: Pool ‹**T**›
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
## Type parameters
|
|
|
|
|
|
|
|
|
|
|
|
▪ **T**
|
|
|
|
|
|
|
|
|
|
|
|
## Hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
* **Pool**
|
|
|
|
|
|
|
|
|
|
|
|
## Index
|
|
|
|
|
|
|
|
|
|
|
|
### Constructors
|
|
|
|
|
|
|
|
|
|
|
|
* [constructor](pool.md#constructor)
|
|
|
|
|
|
|
|
|
|
|
|
### Properties
|
|
|
|
|
|
|
|
|
|
|
|
* [_createCount](pool.md#_createcount)
|
|
|
|
|
|
* [_createFn](pool.md#_createfn)
|
|
|
|
|
|
* [_discardCount](pool.md#_discardcount)
|
|
|
|
|
|
* [_discardFn](pool.md#_discardfn)
|
|
|
|
|
|
* [_inCount](pool.md#_incount)
|
|
|
|
|
|
* [_inFn](pool.md#_infn)
|
|
|
|
|
|
* [_list](pool.md#_list)
|
|
|
|
|
|
* [_max](pool.md#_max)
|
|
|
|
|
|
* [_outCount](pool.md#_outcount)
|
|
|
|
|
|
* [_outFn](pool.md#_outfn)
|
|
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
|
|
|
|
* [allocate](pool.md#allocate)
|
|
|
|
|
|
* [max](pool.md#max)
|
|
|
|
|
|
* [release](pool.md#release)
|
|
|
|
|
|
* [size](pool.md#size)
|
|
|
|
|
|
* [toString](pool.md#tostring)
|
|
|
|
|
|
|
|
|
|
|
|
## Constructors
|
|
|
|
|
|
|
|
|
|
|
|
### constructor
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
\+ **new Pool**(`opts`: object): *[Pool](pool.md)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:31](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L31)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
▪ **opts**: *object*
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-05-08 11:13:58 -07:00
|
|
|
|
`allocate?` | function |
|
|
|
|
|
|
`create?` | function |
|
|
|
|
|
|
`discard?` | function |
|
|
|
|
|
|
`max?` | number |
|
|
|
|
|
|
`release?` | function |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Pool](pool.md)*
|
|
|
|
|
|
|
|
|
|
|
|
## Properties
|
|
|
|
|
|
|
|
|
|
|
|
### _createCount
|
|
|
|
|
|
|
|
|
|
|
|
• **_createCount**: *number* = 0
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:28](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L28)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _createFn
|
|
|
|
|
|
|
|
|
|
|
|
• **_createFn**: *function*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:23](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L23)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
#### Type declaration:
|
|
|
|
|
|
|
|
|
|
|
|
▸ (): *T*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _discardCount
|
|
|
|
|
|
|
|
|
|
|
|
• **_discardCount**: *number* = 0
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:31](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L31)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _discardFn
|
|
|
|
|
|
|
|
|
|
|
|
• **_discardFn**: *function*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:26](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L26)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
#### Type declaration:
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
▸ (`item`: T): *T*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-05-08 11:13:58 -07:00
|
|
|
|
`item` | T |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _inCount
|
|
|
|
|
|
|
|
|
|
|
|
• **_inCount**: *number* = 0
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:30](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L30)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _inFn
|
|
|
|
|
|
|
|
|
|
|
|
• **_inFn**: *function*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:25](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L25)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
#### Type declaration:
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
▸ (`item`: T): *void*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-05-08 11:13:58 -07:00
|
|
|
|
`item` | T |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _list
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
• **_list**: *T[]* = []
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:20](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L20)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _max
|
|
|
|
|
|
|
|
|
|
|
|
• **_max**: *number* = Infinity
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:21](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L21)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _outCount
|
|
|
|
|
|
|
|
|
|
|
|
• **_outCount**: *number* = 0
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:29](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L29)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### _outFn
|
|
|
|
|
|
|
|
|
|
|
|
• **_outFn**: *function*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:24](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L24)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
#### Type declaration:
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
▸ (`item`: T): *void*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-05-08 11:13:58 -07:00
|
|
|
|
`item` | T |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
|
|
|
|
### allocate
|
|
|
|
|
|
|
|
|
|
|
|
▸ **allocate**(): *T*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:61](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L61)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *T*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### max
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
▸ **max**(`n?`: number): *number | [Pool](pool.md)‹T›*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:49](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L49)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-05-08 11:13:58 -07:00
|
|
|
|
`n?` | number |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
**Returns:** *number | [Pool](pool.md)‹T›*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### release
|
|
|
|
|
|
|
|
|
|
|
|
▸ **release**(`item`: T): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:81](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L81)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`item` | T |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### size
|
|
|
|
|
|
|
|
|
|
|
|
▸ **size**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:57](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L57)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### toString
|
|
|
|
|
|
|
|
|
|
|
|
▸ **toString**(): *string*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/util/Pool.ts:96](https://github.com/shakiba/planck.js/blob/acc3bd8/src/util/Pool.ts#L96)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *string*
|