List
Classes
- List
List structure with event signals for observing changes.
Members
List
List structure with event signals for observing changes.
Kind: global class
- List
- new List([array])
- .on
- .data :
Array.<T>
- .length :
number
- .get(index) ⇒
T
|undefined
- .set(index, value)
- .add(el) ⇒
this
- .addUnique(el) ⇒
boolean
- .insert(index, el) ⇒
List
- .crop(startIndex, endIndex) ⇒
number
- .patch(new_data)
- .addAll(elements)
- .addAllUnique(elements)
- .removeMany(index, removeCount) ⇒
Array.<T>
- .remove(index) ⇒
T
- .removeAll(elements) ⇒
boolean
- .removeOneOf(value) ⇒
boolean
- .sort([compare_function]) ⇒
this
- .clone() ⇒
List.<T>
- .slice([start], [end]) ⇒
Array.<T>
- .some(condition) ⇒
boolean
- .removeIf(condition, [thisArg])
- .removeOneIf(condition, [thisArg]) ⇒
boolean
- .forEach(f, [thisArg])
- .reduce(f, initial) ⇒
*
- .filter(f) ⇒
Array.<T>
- .find(matcher) ⇒
T
|undefined
- .findIndex(matcher) ⇒
number
- .visitFirstMatch(matcher, callback) ⇒
boolean
- .contains(v) ⇒
boolean
- .containsAny(options) ⇒
boolean
- .isEmpty() ⇒
boolean
- .indexOf(el) ⇒
number
- .map(callback, [thisArg]) ⇒
Array.<R>
.resetViaCallback(callback, [thisArg])- .deepCopy(other, [removeCallback], [thisArg])
- .copy(other)
- .asArray() ⇒
Array.<T>
- .fromJSON(json, constructor)
- .toBinaryBuffer(buffer)
- .fromBinaryBuffer(buffer, constructor)
- .fromBinaryBufferViaFactory(buffer, factory)
- .addFromBinaryBufferViaFactory(buffer, factory)
- .addFromJSONViaFactory(data, factory)
- .hash() ⇒
number
- .first() ⇒
T
|undefined
- .last() ⇒
T
|undefined
- .equals(other)
- .compare(other) ⇒
number
new List([array])
Param | Type |
---|---|
[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
Param | Type |
---|---|
index | number |
list.set(index, value)
Set element at a given position inside the list
Kind: instance method of List
Param | Type |
---|---|
index | number |
value | T |
list.add(el) ⇒ this
Kind: instance method of List
Param | Type |
---|---|
el | T |
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
Param | Type |
---|---|
el | T |
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
Param | Type |
---|---|
index | number |
el | T |
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
Param | Type | Description |
---|---|---|
startIndex | int | |
endIndex | int | up 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
Param | Type |
---|---|
new_data | Array.<T> |
list.addAll(elements)
Kind: instance method of List
Param | Type |
---|---|
elements | Array.<T> |
list.addAllUnique(elements)
Kind: instance method of List
Param | Type |
---|---|
elements | Array.<T> |
list.removeMany(index, removeCount) ⇒ Array.<T>
Kind: instance method of List
Param | Type |
---|---|
index | number |
removeCount | number |
list.remove(index) ⇒ T
Kind: instance method of List
Param | Type |
---|---|
index | number |
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
Param | Type |
---|---|
elements | Array.<T> |
list.removeOneOf(value) ⇒ boolean
Kind: instance method of List
Param | Type |
---|---|
value | T |
list.sort([compare_function]) ⇒ this
Kind: instance method of List
Param | Type |
---|---|
[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
Param | Type |
---|---|
[start] | number |
[end] | number |
list.some(condition) ⇒ boolean
Kind: instance method of List
Param | Type |
---|---|
condition | function |
list.removeIf(condition, [thisArg])
Kind: instance method of List
Param | Type | Description |
---|---|---|
condition | function | must return boolean value |
[thisArg] | * |
list.removeOneIf(condition, [thisArg]) ⇒ boolean
Kind: instance method of List
Param | Type |
---|---|
condition | function |
[thisArg] | * |
list.forEach(f, [thisArg])
INVARIANT: List length must not change during the traversal
Kind: instance method of List
Param | Type |
---|---|
f | function |
[thisArg] | * |
list.reduce(f, initial) ⇒ *
Kind: instance method of List
Param | Type |
---|---|
f | function |
initial | * |
list.filter(f) ⇒ Array.<T>
Kind: instance method of List
Param | Type |
---|---|
f | function |
list.find(matcher) ⇒ T
| undefined
Kind: instance method of List
Param | Type |
---|---|
matcher | function |
list.findIndex(matcher) ⇒ number
Kind: instance method of List
Returns: number
- Index of the first match or -1
Param | Type |
---|---|
matcher | function |
list.visitFirstMatch(matcher, callback) ⇒ boolean
Kind: instance method of List
Param | Type |
---|---|
matcher | function |
callback | function |
list.contains(v) ⇒ boolean
Kind: instance method of List
Param | Type |
---|---|
v | T |
list.containsAny(options) ⇒ boolean
Does the list contain at least one of the given options?
Kind: instance method of List
Param | Type |
---|---|
options | Array.<T> |
list.isEmpty() ⇒ boolean
List has no elements
Kind: instance method of List
list.indexOf(el) ⇒ number
Kind: instance method of List
Param | Type |
---|---|
el | T |
list.map(callback, [thisArg]) ⇒ Array.<R>
Kind: instance method of List
Param | Type |
---|---|
callback | function |
[thisArg] | * |
list.resetViaCallback(callback, [thisArg])
Deprecated
Kind: instance method of List
Param | Type |
---|---|
callback | function |
[thisArg] | * |
list.deepCopy(other, [removeCallback], [thisArg])
Note that elements must have .clone method for this to work
Kind: instance method of List
Param | Type | Description |
---|---|---|
other | List.<T> | |
[removeCallback] | function | |
[thisArg] | * | Used on removeCallback |
list.copy(other)
Kind: instance method of List
Param | Type |
---|---|
other | List.<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
Param | Type |
---|---|
json | Array.<J> |
constructor | function |
list.toBinaryBuffer(buffer)
Kind: instance method of List
Param | Type |
---|---|
buffer | BinaryBuffer |
list.fromBinaryBuffer(buffer, constructor)
Kind: instance method of List
Param | Type |
---|---|
buffer | BinaryBuffer |
constructor |
list.fromBinaryBufferViaFactory(buffer, factory)
Kind: instance method of List
Param | Type |
---|---|
buffer | BinaryBuffer |
factory | function |
list.addFromBinaryBufferViaFactory(buffer, factory)
Kind: instance method of List
Param | Type |
---|---|
buffer | BinaryBuffer |
factory | function |
list.addFromJSONViaFactory(data, factory)
Kind: instance method of List
Param | Type |
---|---|
data | Array.<J> |
factory | function |
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
Param | Type |
---|---|
other | List |
list.compare(other) ⇒ number
Kind: instance method of List
Param | Type |
---|---|
other | List.<T> |
added : Signal.<T, number>
Kind: global variable
Read only: true
removed : Signal.<T, number>
Kind: global variable
Read only: true