Sealed Private length_record linked list length
Protected opts_Private root_sentinel list element, only root, root.prev, and root.next are used
returns the capacity of the linked list
Returns true if there is no data in the container
Returns true if the container has reached the container limit
Returns true if there is data in the container
Returns true if the container has not reached the container limit
returns the length of the linked list
Sealed
Returns an object that implements a js Iterable, but it traverses the data in reverse
Private _insertinsert inserts e after at, increments length
Private _insertPrivate _movemove moves e to next to at and returns e.
Private _removeremove removes e from its list, decrements length
returns the last element of list l or nil if the list is empty.
clear the list
It will cause a bug if a call to remove is passed after calling clear and an element before clear is passed in. like this
const l = new List<number>()
const ele = l.pushBack(1)
l.cear()
console.log((l.remove(ele)) // output true
console.log(l.length) // output -1
This bug is generated because the element records which linked list it is in and the clear function does not clear the mark .
So remove(ele) mistakenly deletes the expired element. To solve this problem, it is necessary to traverse the linked list once in 'clear' to clear all tags, but this will damage efficiency. However, this bug is not common and the caller can be avoided, so I'm not going to fix it.
You can also avoid this bug by passing in an empty implementation of the callback function, because calling the callback for all elements also requires traversing the list once, so in this case the code also empties the token before the callback.
const l = new List<number>()
const ele = l.pushBack(1)
l.cear(()=>{})
console.log((l.remove(ele)) // output false
console.log(l.length) // output 0
Optional callback: DeleteCallback<T>call the callback on the removed element
Create a full copy of the container
Optional callback: CloneCallback<T>How to create a duplicate copy of an element
Returns true if the data depth of the two containers is consistent
Optional callback: CompareCallback<T>Traverse the container looking for elements until the callback returns true, then stop looking
whether the element was found
Determine whether it is the element to be found
Optional reverse: booleanIf true, traverse the container in reverse order
call callback on each element in the container in turn
Optional reverse: booleanIf true, traverse the container in reverse order
returns the first element of list l or undefined if the list is empty.
Returns whether the data data exists in the container
Optional reverse: booleanOptional callback: CompareCallback<T>inserts a new element e with value v immediately after mark and returns e.
inserts a new element e with value v immediately before mark and returns e.
Adds all the elements of an container into a string, separated by the specified separator string.
Optional separator: stringA string used to separate one element of the container from the next in the resulting string. If omitted, the array elements are separated with a comma.
Optional callback: MapCallback<T, TO>Optional reverse: booleanIf true, traverse the container in reverse order
Convert container to array
Optional reverse: booleanIf true, traverse the container in reverse order
moves element e to its new position after mark.
moves element e to its new position before mark.
moves element e to the back of list.
moves element e to the front of list.
If the list is not empty delete the element at the back
deleted data
Optional callback: DeleteCallback<T>call the callback on the removed element
If the list is not empty delete the element at the back
deleted data
Optional callback: DeleteCallback<T>call the callback on the removed element
If the list is not empty delete the element at the front
deleted data
Optional callback: DeleteCallback<T>call the callback on the removed element
If the list is not empty delete the element at the front
deleted data
Optional callback: DeleteCallback<T>call the callback on the removed element
inserts a new element e with value v at the back of list and returns e.
inserts a copy of another container at the back of list.
Optional callback: CloneCallback<T>inserts a new element e with value v at the front of list and returns e.
inserts a copy of another container at the front of list l.
Optional callback: CloneCallback<T>remove e from list if e is an element of list.
element to remove
Optional callback: DeleteCallback<T>call the callback on the removed element
Generated using TypeDoc
Doubly linked list. Refer to the golang standard library implementation