new PrioArray(prioopt)
Priority Array-like class.
Provides generic priority array operations.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
prio |
number |
<optional> |
The default element priority. 0 if omitted. |
Extends
Members
defaultPriority :number
The default element priority.
Type:
- number
(readonly) maxPriority :number
The maximum priority in array.
Type:
- number
(readonly) minPriority :number
The minimum priority in array.
Type:
- number
Methods
add(elem, prio) → {number}
Adds an element to array with specified priority.
Parameters:
Name | Type | Description |
---|---|---|
elem |
* | An element to add. |
prio |
number | A priority of the element. |
Returns:
An index of element in array.
- Type
- number
pop() → {*}
Removes the last element from this array and returns that element.
Returns:
The removed element or undefined if empty array.
- Type
- *
push(…varargs) → {number}
Adds one or more elements at end of this array, assigning them maximum
priority present in this array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
varargs |
* |
<repeatable> |
The elements to add to the end of the array. |
Returns:
The new length of this array.
- Type
- number
remove(elem) → {*}
Removes an element from this array.
Parameters:
Name | Type | Description |
---|---|---|
elem |
* | The element to remove. |
Returns:
The removed element, or null if element not found in array.
- Type
- *
removeAt(index) → {*}
Removes an element at specified index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | An index of an element in array to remove. |
Returns:
The removed element, or null if index is out of bounds.
- Type
- *