IntPool

class emlib.containers.IntPool(capacity, start=0)[source]

Bases: object

A pool of intergers

A pool will contain the integers in the range [0, capacity)

Parameters:

capacity (int) – the capacity (size) of the pool.

Example

>>> from emlib.containers import IntPool
>>> pool = IntPool(10)
>>> token = pool.pop()
>>> len(pool)
9
>>> pool.push(token)
>>> len(pool)
10
>>> pool.push(4)
ValueError: token 4 already in pool

Methods Summary

pop()

rtype:

int

push(token)

rtype:

None

Methods Documentation

pop()[source]
Return type:

int

push(token)[source]
Return type:

None