dastal - v5.0.0 / LinkedList
A (circular) linked list implementation of the List interface.
Name |
---|
T |
- List<T>
- [iterator]
- add
- addAll
- clear
- concat
- copyWithin
- fill
- get
- getSet
- pop
- push
- remove
- reverse
- set
- shift
- slice
- sort
- splice
- unshift
- update
- view
• new LinkedList<T>(elements?
)
Instantiate the list.
Name |
---|
T |
Name | Type | Description |
---|---|---|
elements? |
Iterable <T> |
A set of elements to initialize the list with. |
• get
size(): number
The number of elements in the collection.
number
▸ [iterator](): Iterator
<T, any, undefined>
Receive an iterator through the list.
Note: Unexpected behavior can occur if the collection is modified during iteration.
Iterator
<T, any, undefined>
An iterator through the list
▸ add(index
, value
): number
Add the element at the specified index.
Name | Type |
---|---|
index |
number |
value |
T |
number
▸ addAll(index
, elements
): number
Add elements at the specified index.
Name | Type |
---|---|
index |
number |
elements |
Iterable <T> |
number
▸ clear(): void
Removes all elements.
void
▸ concat(...lists
): LinkedList<T>
Combines the list with multiple iterables into a new list. Does not modify the existing list or inputs.
Name | Type |
---|---|
...lists |
Iterable <T>[] |
LinkedList<T>
▸ copyWithin(index
, min?
, max?
): LinkedList<T>
Copies a section of the list identified by min and max to the same array at position index.
Negative indices can be used for index, min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Note that this method will not change the size of the list. If index is after min, the copied sequence will be trimmed to fit list.size
Name | Type |
---|---|
index |
number |
min? |
number |
max? |
number |
LinkedList<T>
▸ fill(element
, min?
, max?
): LinkedList<T>
Returns the this object after filling the section identified by min and max with element.
Negative indices can be used for min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
element |
T |
min? |
number |
max? |
number |
LinkedList<T>
▸ get(index
): undefined
| T
Return the element at the specified index.
Name | Type |
---|---|
index |
number |
undefined
| T
▸ getSet(index
, callback
): undefined
| T
Update the element at the specified index.
Name | Type |
---|---|
index |
number |
callback |
(element : T ) => T |
undefined
| T
▸ pop(): undefined
| T
Retrieves and removes the end of the list.
undefined
| T
▸ push(value
): number
Inserts the specified value into the end of the list
Name | Type |
---|---|
value |
T |
number
▸ remove(index
): undefined
| T
Retrieves and removes the element at the given index.
A negative index can be used to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
index |
number |
undefined
| T
▸ reverse(min?
, max?
): LinkedList<T>
Reverses the elements in the list in place.
Negative indices can be used for min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
min? |
number |
max? |
number |
LinkedList<T>
▸ set(index
, element
): undefined
| T
Update the element at the specified index.
Name | Type |
---|---|
index |
number |
element |
T |
undefined
| T
▸ shift(): undefined
| T
Retrieves and removes the first element in the list.
undefined
| T
▸ slice(min?
, max?
): LinkedList<T>
Returns a copy of a section of the list.
Negative indices can be used for min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
min? |
number |
max? |
number |
LinkedList<T>
▸ sort(compareFn
): LinkedList<T>
Sorts the elements in place.
Name | Type |
---|---|
compareFn |
CompareFn<T> |
LinkedList<T>
▸ splice(start?
, count?
, elements?
): List<T>
Removes elements from the list and optionally inserts new elements in their place. Returns any deleted elements.
Name | Type |
---|---|
start? |
number |
count? |
number |
elements? |
Iterable <T> |
List<T>
▸ unshift(value
): number
Inserts the specified value into the front of the list
Name | Type |
---|---|
value |
T |
number
▸ update(callback
): LinkedList<T>
Update the elements of the list
Name | Type |
---|---|
callback |
(element : T , index : number ) => T |
LinkedList<T>
▸ update(min
, callback
): LinkedList<T>
Update the elements of the list
Negative indices can be used to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
min |
undefined | number |
callback |
(element : T , index : number ) => T |
LinkedList<T>
▸ update(min
, max
, callback
): LinkedList<T>
Update the elements of the list
Negative indices can be used for min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Name | Type |
---|---|
min |
undefined | number |
max |
undefined | number |
callback |
(element : T , index : number ) => T |
LinkedList<T>
▸ view(min?
, max?
): Iterable
<T>
Receive an iterator through a section of the list.
Negative indices can be used for min and max to indicate an offset from the end of the list. For example, -2 refers to the second to last element of the list.
Note: Unexpected behavior can occur if the collection is modified during iteration.
Name | Type |
---|---|
min? |
number |
max? |
number |
Iterable
<T>