The type of element in this collection.
Creates a singly-linked list, optionally filled with the elements generated by the given iterable.
const l = new DoubleinkedList();
You can also construct a linked list from any iterable, like so:
const l = new DoubleLinkedList([1, 2, 3])
Count the amount of elements in the collection.
⚠️ In most cases, this should be an O(1)
operation. However, there are
cases where this can be an O(n)
operation. Therefore, it is recommended
to always cache the result in a local variable.
Returns an object which is able to sift through the values in this collection.
The order by which the elements are traversed depends on the kind of collection. For unordered collections, the iteration order is unspecified and may even differ between two iterations on the same collection.
Return a cursor that is placed at the index given by position
in the
sequence.
Remove all elements from this collection, effectively setting the collection to the empty collection.
Copies all elements in the collection to a new one of the same kind.
Get the first element in the sequence.
Allows taking an element directly out of the collection at a given position.
This method might be faster than at because it is not forced to construct a cursor object.
Get the last element in the collection.
Get the rest of the list. This operation usually is in O(1)
.
Converts the entire collection to a range.
Will create a doubly-linked list filled with the elements generated by the given iterable.
Generated using TypeDoc
A doubly-linked list, which is sometimes faster than a singly-linked list but consumes a bit more memory.
The following table summarises the time complexity of the most commonly used properties.
SingleLinkedList