OrderedCollection
Constructor
constructor
constructor(classOf, values = null): OrderedCollection<classOf>
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
classOf | string | Yes | null | Referencing the type of AbstractEntity included in the OrderedCollection |
values | Array<Reference | number | AbstractEntity > | No | [] |
Properties
classOf
Type | Description |
---|---|
string | Referencing the type of AbstractEntity included in the OrderedCollection |
size
Type | Description |
---|---|
int |
values
The reference array ordered
Type | Description |
---|---|
Array<Reference> |
Read-Only
Protocols
Iterator
Iterate elements in the proper order
Returns:
Type: Array<Reference>
Methods
add
Add an element to the ordered collection
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
value | Reference | AbstractEntity | int | symbol | Yes | - | The value to add to the OrderedCollection, if your providing Reference or AbstractEntity make sure it's match with the classOf property |
position | int | null | No | null | The position to insert the element, if null or position >= size property it will be added in the last position |
Please note that inserting element at a defined position comes with a performance cost. If you need to add multiple elements prefer the set method.
Returns:
Type: this
at
Get an element from the ordered collection by it's index
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
index | int | null | Yes | - | The index of the ordered collection you want to retrieve, null if not found (i.e. index >= size |
Returns:
Type: Reference
clear
Empty the OrderedCollection
Parameters:
Name | Type | Required | Default | Description |
---|
Returns:
Type: this
forEach
Executes a provided function once for each OrderedCollection element in the proper order
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
callback | function(Reference) | Yes | - |
Returns:
Type: this
has
Indicates whether an element with the specified value exists in the OrderedCollection or not.
The existence will be tested against Reference#is method.
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
value | Reference | AbstractEntity | int | symbol | Yes | - | The value to test existence in the OrderedCollection, if your providing Reference or AbstractEntity make sure it's match with the classOf property |
Returns:
Type: boolean
indexOf
Find the index (i.e. the position) at which a given element can be found in the OrderedCollection, or -1 if it is not present.
The existence will be tested against Reference#is method.
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
value | Reference | AbstractEntity | int | symbol | Yes | - | The value to test existence in the OrderedCollection, if your providing Reference or AbstractEntity make sure it's match with the classOf property |
Returns:
Type: int
remove
Remove an element from the OrderedCollection
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
value | Reference | AbstractEntity | int | symbol | Yes | - | The value to remove from the OrderedCollection, if your providing Reference or AbstractEntity make sure it's match with the classOf property |
Returns:
Type: this
removeAt
Remove an element from the OrderedCollection using its position
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
index | int | Yes | - |
Returns:
Type: this
set
Set the OrderedCollection, it is equivalent to clear then add successively all elements to the OrderedCollection
Parameters:
Name | Type | Required | Default | Description |
---|---|---|---|---|
values | Iterable<{ id: Reference | AbstractEntity | int | symbol, position: int }> | Yes | - | Iif your providing Reference or AbstractEntity make sure it's match with the classOf property |
Returns:
Type: this