Skip to main content

List

Classes

List

List structure with event signals for observing changes.

Members

added : Signal.<T, number>
removed : Signal.<T, number>

List

List structure with event signals for observing changes.

Kind: global class

new List([array])

ParamType
[array]Array.<T>

list.on

Kind: instance property of List
Read only: true

list.data : Array.<T>

Kind: instance property of List
Read only: true

list.length : number

Number of elements in the list

Kind: instance property of List

list.get(index) ⇒ T | undefined

Retrieve element at a given position in the list

Kind: instance method of List

ParamType
indexnumber

list.set(index, value)

Set element at a given position inside the list

Kind: instance method of List

ParamType
indexnumber
valueT

list.add(el) ⇒ this

Kind: instance method of List

ParamType
elT

list.addUnique(el) ⇒ boolean

Only add element if it doesn't already exist in the list Useful when you wish to ensure uniqueness of elements inside the list Note that this operation is rather slow as it triggers a linear scan If the list gets large - consider using a Set class instead

Kind: instance method of List
Returns: boolean - true if element was added, false if element already existed in the list

ParamType
elT

list.insert(index, el) ⇒ List

Insert element at a specific position into the list This operation will result in a larger list

Kind: instance method of List
Throws:

  • Error when trying to insert past list end
ParamType
indexnumber
elT

list.crop(startIndex, endIndex) ⇒ number

Reduces the list to a subsection but removing everything before startIndex and everything after endIndex

Kind: instance method of List

ParamTypeDescription
startIndexint
endIndexintup to this index, not including it

list.patch(new_data)

Replace the data, replacements is performed surgically, meaning that diff is computed and add/remove operations are performed on the set This method is tailored to work well with visualisation as only elements that's missing from the new set is removed, and only elements that are new to are added Conversely, relevant events are dispatched that can observe. This results in fewer changes required to the visualisation

Kind: instance method of List

ParamType
new_dataArray.<T>

list.addAll(elements)

Kind: instance method of List

ParamType
elementsArray.<T>

list.addAllUnique(elements)

Kind: instance method of List

ParamType
elementsArray.<T>

list.removeMany(index, removeCount) ⇒ Array.<T>

Kind: instance method of List

ParamType
indexnumber
removeCountnumber

list.remove(index) ⇒ T

Kind: instance method of List

ParamType
indexnumber

list.removeAll(elements) ⇒ boolean

Kind: instance method of List
Returns: boolean - True is all specified elements were found and removed, False if some elements were not present in the list

ParamType
elementsArray.<T>

list.removeOneOf(value) ⇒ boolean

Kind: instance method of List

ParamType
valueT

list.sort([compare_function]) ⇒ this

Kind: instance method of List

ParamType
[compare_function]function

list.clone() ⇒ List.<T>

Copy of this list

Kind: instance method of List

list.slice([start], [end]) ⇒ Array.<T>

Returns a shallow copy array with elements in range from start to end (end not included) Same as Array.prototype.slice

Kind: instance method of List

ParamType
[start]number
[end]number

list.some(condition) ⇒ boolean

Kind: instance method of List

ParamType
conditionfunction

list.removeIf(condition, [thisArg])

Kind: instance method of List

ParamTypeDescription
conditionfunctionmust return boolean value
[thisArg]*

list.removeOneIf(condition, [thisArg]) ⇒ boolean

Kind: instance method of List

ParamType
conditionfunction
[thisArg]*

list.forEach(f, [thisArg])

INVARIANT: List length must not change during the traversal

Kind: instance method of List

ParamType
ffunction
[thisArg]*

list.reduce(f, initial) ⇒ *

Kind: instance method of List

ParamType
ffunction
initial*

list.filter(f) ⇒ Array.<T>

Kind: instance method of List

ParamType
ffunction

list.find(matcher) ⇒ T | undefined

Kind: instance method of List

ParamType
matcherfunction

list.findIndex(matcher) ⇒ number

Kind: instance method of List
Returns: number - Index of the first match or -1

ParamType
matcherfunction

list.visitFirstMatch(matcher, callback) ⇒ boolean

Kind: instance method of List

ParamType
matcherfunction
callbackfunction

list.contains(v) ⇒ boolean

Kind: instance method of List

ParamType
vT

list.containsAny(options) ⇒ boolean

Does the list contain at least one of the given options?

Kind: instance method of List

ParamType
optionsArray.<T>

list.isEmpty() ⇒ boolean

List has no elements

Kind: instance method of List

list.indexOf(el) ⇒ number

Kind: instance method of List

ParamType
elT

list.map(callback, [thisArg]) ⇒ Array.<R>

Kind: instance method of List

ParamType
callbackfunction
[thisArg]*

list.resetViaCallback(callback, [thisArg])

Deprecated

Kind: instance method of List

ParamType
callbackfunction
[thisArg]*

list.deepCopy(other, [removeCallback], [thisArg])

Note that elements must have .clone method for this to work

Kind: instance method of List

ParamTypeDescription
otherList.<T>
[removeCallback]function
[thisArg]*Used on removeCallback

list.copy(other)

Kind: instance method of List

ParamType
otherList.<T> | Array.<T>

list.asArray() ⇒ Array.<T>

NOTE: do not modify resulting array

Kind: instance method of List

list.fromJSON(json, constructor)

Kind: instance method of List

ParamType
jsonArray.<J>
constructorfunction

list.toBinaryBuffer(buffer)

Kind: instance method of List

ParamType
bufferBinaryBuffer

list.fromBinaryBuffer(buffer, constructor)

Kind: instance method of List

ParamType
bufferBinaryBuffer
constructor

list.fromBinaryBufferViaFactory(buffer, factory)

Kind: instance method of List

ParamType
bufferBinaryBuffer
factoryfunction

list.addFromBinaryBufferViaFactory(buffer, factory)

Kind: instance method of List

ParamType
bufferBinaryBuffer
factoryfunction

list.addFromJSONViaFactory(data, factory)

Kind: instance method of List

ParamType
dataArray.<J>
factoryfunction

list.hash() ⇒ number

NOTE: Elements must have hash method

Kind: instance method of List

list.first() ⇒ T | undefined

First element in the list

Kind: instance method of List

list.last() ⇒ T | undefined

Last element in the list

Kind: instance method of List

list.equals(other)

Perform element-wise equality comparison with another list

Kind: instance method of List

ParamType
otherList

list.compare(other) ⇒ number

Kind: instance method of List

ParamType
otherList.<T>

added : Signal.<T, number>

Kind: global variable
Read only: true

removed : Signal.<T, number>

Kind: global variable
Read only: true