Class: Counter

Counter~Counter

Class representing allocatable and deallocatable counters Counters are allocated in sequential manner, this applies to deallocated counters Once a counter is deallocated, it will be reused on the next allocation

Constructor

new Counter(beginopt, blockSizeopt)

Creates a counter instance
Parameters:
Name Type Attributes Description
begin number <optional>
Defaults to 0
blockSize number <optional>
Must be a multiple of 32, defaults to 32
Source:

Methods

allocate(counteropt) → {number|boolean}

Allocates a counter sequentially If a counter is specified, it will allocate it explicitly But it will skip over intermediate children, and subsequent allocations is still sequential
Parameters:
Name Type Attributes Description
counter number <optional>
Source:
Throws:
- Will throw if the explicitly allocated counter is out of bounds
Type
RangeError
Returns:
Type
number | boolean

check(counter) → {boolean}

Checks if a number has been allocated or not
Parameters:
Name Type Description
counter number
Source:
Returns:
Type
boolean

deallocate(counter) → {boolean}

Deallocates a number, it makes it available for reuse
Parameters:
Name Type Description
counter number
Source:
Returns:
Type
boolean