Class: PriorityList

sjl.stdlib. PriorityList


new PriorityList(objOrArray, LIFO, wrapItems)

Allows the sorting of items based on priority (serial index (order items were entered in) is also taken into account when items have the same priority). This class also implements the es6 `Map` interface and the es6 `Iterator` interface thereby making it easily manageable and iterable.
Parameters:
Name Type Description
objOrArray Object | Array Required.
LIFO Boolean "Last In First Out" flag. Default false.
wrapItems Boolean Whether items should be wrapped (internal priority list props set on outer wrapper) or whether items should not be wrapped (internal priority list properties set directly on passed in objects) (internal props used for sorting and other internal calculations). Default false.

Extends

Members


<readonly> _iteratorOverridden :Boolean

Flag for knowing that es6 iterator was overridden. Set on construction.
Type:
  • Boolean
Inherited From:

<readonly> _keys :Array

Keys array. Set on construction.
Type:
  • Array
Inherited From:

<readonly> _values :Array

Values array. Set on construction.
Type:
  • Array
Inherited From:
Overrides:

pointer :Number

Iterator pointer.
Type:
  • Number
Inherited From:

<readonly> size :Number

Size of the iterator.
Type:
  • Number
Inherited From:
Overrides:

Methods


addFromArray(array)

Adds key-value array pairs in an array to this instance.
Parameters:
Name Type Description
array Array.<Array.<*, *>> Array of key-value array entries to parse.
Inherited From:
Returns:
Type
SjlMap

addFromObject(object)

Add all the `object`'s instance's own property key-value pairs to this instance.
Parameters:
Name Type Description
object Object Object to operate on.
Inherited From:
Returns:
Type
SjlMap

clear()

Clears the `SjlMap` object of all data that has been set on it.
Inherited From:
Returns:
Type
SjlMap

current()

Returns the current value that `pointer` is pointing to.
Inherited From:
Returns:
Type
Object

delete(key)

Deletes an entry in the `SjlMap`.
Parameters:
Name Type Description
key * Key of key-value pair to remove.
Inherited From:
Returns:
Type
SjlMap

entries()

Returns the entries in this `SjlMap` as a valid es6 iterator to iterate over (usable in older versions of javascript).
Inherited From:
Returns:
Type
sjl.stdlib.ObjectIterator

forEach(callback, context)

Iterates through all key value pairs in itself and passes them to `callback` on each iteration.
Parameters:
Name Type Description
callback function Required.
context Object Optional.
Inherited From:
Overrides:
Returns:
Type
SjlMap

get(key)

Returns the value "set" for a key in instance.
Parameters:
Name Type Description
key *
Inherited From:
Returns:
Type
*

has(key)

Returns whether a `key` is set on this `SjlMap`.
Parameters:
Name Type Description
key * Required.
Inherited From:
Returns:
Type
boolean

iterator()

Returns a valid es6 iterator to iterate over key-value pair entries of this instance. (same as `SjlMap#entries`).
Inherited From:
Returns:
Type
sjl.stdlib.ObjectIterator

keys()

Returns the keys in this `SjlMap` as a valid es6 iterator object to iterate over (usable in older versions of javascript).
Inherited From:
Returns:
Type
sjl.stdlib.Iterator

next()

Method which returns the current position in the iterator based on where the pointer is. This method also increases the pointer after it is done fetching the value to return.
Inherited From:
Returns:
Type
Object

rewind()

Rewinds the iterator.
Inherited From:
Returns:
Type
sjl.stdlib.Iterator

set(key, value)

Sets a key-value pair in this instance.
Parameters:
Name Type Description
key * Key to set.
value * Value to set.
Inherited From:
Returns:
Type
SjlMap

toJSON()

Shallow to json method.
Inherited From:
Returns:
Type
Object

valid()

Returns whether the iterator has reached it's end.
Inherited From:
Returns:
Type
boolean

values()

Returns the values in this `SjlMap` as a valid es6 iterator object to iterate over (usable in older versions of javascript).
Inherited From:
Returns:
Type
sjl.stdlib.Iterator