Skip to main content

IdPool

IdPool

Pool of unsigned integer IDs, useful when you don't want to just keep incrementing ID counter and want to re-use IDs after they are no longer needed Main use case is when your IDs are array indices, having compact IDs lets you use fixed size array even as objects are added and removed as you're able to reuse slots in an efficient manner

Kind: global class

idPool.peek() ⇒ number

Looks up next available ID without reserving it If you want to also reserve the ID - use get instead

Kind: instance method of IdPool

idPool.get() ⇒ number

Kind: instance method of IdPool

idPool.getSpecific(id) ⇒ boolean

Attempt to request a specific ID from the pool.

Kind: instance method of IdPool
Returns: boolean - true if request succeeds, false otherwise

ParamType
idnumber

idPool.isUsed(id) ⇒ boolean

Kind: instance method of IdPool

ParamType
idnumber

idPool.traverseUsed(visitor)

Traverse all IDs currently in use

Kind: instance method of IdPool

ParamType
visitorfunction

idPool.release(id)

Kind: instance method of IdPool

ParamType
idnumber

idPool.reset()

Release all used IDs

Kind: instance method of IdPool