Typed API (TypeDoc) / CyclicDoublyLinkedList
Class: CyclicDoublyLinkedList<E>
Defined in: list.ts:1507
Type Parameters
E
E
Implements
ILinkedList<E>
Constructors
Constructor
new CyclicDoublyLinkedList<
E>(elements?,reverse?):CyclicDoublyLinkedList<E>
Defined in: list.ts:1525
Parameters
elements?
Iterable<E, any, any>
reverse?
boolean = false
Returns
CyclicDoublyLinkedList<E>
Properties
comparator
comparator:
Comparator<E>
Defined in: list.ts:1523
Comparator used for equality/sort checks.
Implementation of
first
first:
Node<E>
Defined in: list.ts:1511
Head node reference.
Implementation of
last
last:
Node<E>
Defined in: list.ts:1515
Tail node reference.
Implementation of
size
size:
number=0
Defined in: list.ts:1519
Current element count.
Implementation of
Methods
[iterator]()
[iterator]():
Iterator<E>
Defined in: list.ts:1981
Iterates through the whole CyclicDoublyLinkedList.
Returns
Iterator<E>
Iterator for the CyclicDoublyLinkedList.
Remarks
Complexity: O(size)
Implementation of
ILinkedList.[iterator]
add()
add(
e):void
Defined in: list.ts:1537
Append an element.
Parameters
e
E
Returns
void
Remarks
Complexity: Amortized O(1) unless stated otherwise.
Implementation of
addAll()
addAll(
c):void
Defined in: list.ts:1544
Append every element from another collection.
Parameters
c
Iterable<E>
Returns
void
Remarks
Complexity: O(n + m) where m is collection.size.
Implementation of
addFirst()
addFirst(
e):void
Defined in: list.ts:1553
Insert at the beginning.
Parameters
e
E
Returns
void
Remarks
Complexity: O(1)
Implementation of
addLast()
addLast(
e):void
Defined in: list.ts:1583
Insert at the end.
Parameters
e
E
Returns
void
Remarks
Complexity: O(1)
Implementation of
clear()
clear():
void
Defined in: list.ts:1608
Remove all entries.
Returns
void
Remarks
Complexity: O(n)
Implementation of
contains()
contains(
element):boolean
Defined in: list.ts:1921
Test membership using the comparator when available.
Parameters
element
E
Returns
boolean
Remarks
Complexity: O(n) worst case
Implementation of
equals()
equals(
l):boolean
Defined in: list.ts:1928
Compare equality value-by-value using the comparator.
Parameters
l
IList<E>
List to compare.
Returns
boolean
true when lengths match and all elements compare equal.
Implementation of
every()
every(
predicate):boolean
Defined in: list.ts:1745
Test whether every element matches the predicate.
Parameters
predicate
(e) => boolean
Match callback.
Returns
boolean
true when all elements satisfy the predicate.
Remarks
Complexity: O(n)
Implementation of
filter()
filter(
predicate):CyclicDoublyLinkedList<E>
Defined in: list.ts:1732
Create a list containing values that satisfy the predicate.
Parameters
predicate
(e) => boolean
Filter callback.
Returns
CyclicDoublyLinkedList<E>
Filtered list.
Remarks
Complexity: O(n)
Implementation of
get()
get(
index):E
Defined in: list.ts:1616
Read the element at a given index.
Parameters
index
number
Zero-based index.
Returns
E
Element at the index.
Remarks
Complexity: O(1) for List, O(n) for linked variants.
Implementation of
getFirst()
getFirst():
E
Defined in: list.ts:1774
Read the first element.
Returns
E
Implementation of
getLast()
getLast():
E
Defined in: list.ts:1782
Read the last element.
Returns
E
Implementation of
getNode()
getNode(
index):Node<E>
Defined in: list.ts:1899
Retrieve the internal node at index.
Parameters
index
number
Returns
Node<E>
Remarks
Complexity: O(n)
Implementation of
indexOf()
indexOf(
element,startIndex):number
Defined in: list.ts:1940
Locate the first matching element starting at startIndex.
Parameters
element
E
Needle value.
startIndex
number = 0
Optional search start.
Returns
number
Index or -1.
Remarks
Complexity: O(n)
Implementation of
isEmpty()
isEmpty():
boolean
Defined in: list.ts:1791
Check for emptiness.
Returns
boolean
true when size === 0.
Implementation of
map()
map<
V>(fn):CyclicDoublyLinkedList<V>
Defined in: list.ts:1710
Transform each element.
Type Parameters
V
V
Result type.
Parameters
fn
(e) => V
Mapper invoked per element.
Returns
CyclicDoublyLinkedList<V>
New list containing mapped values.
Remarks
Complexity: O(n)
Implementation of
reduce()
reduce<
V>(fn,initialValue?):V
Defined in: list.ts:1721
Reduce the list to a single value.
Type Parameters
V
V
Accumulator type.
Parameters
fn
(accumulator, element) => V
Reducer callback.
initialValue?
V
Optional starting value.
Returns
V
Accumulated result.
Remarks
Complexity: O(n)
Implementation of
remove()
remove(
target,isIndex):number|E
Defined in: list.ts:1818
Remove by value or index.
Parameters
target
Element or index.
number | E
isIndex
boolean = true
When true, treat e as index.
Returns
number | E
Removed element or index of removal.
Remarks
Complexity: O(n) worst case.
Implementation of
removeFirst()
removeFirst():
E
Defined in: list.ts:1828
Remove and return the head value.
Returns
E
Remarks
Complexity: O(1)
Implementation of
removeLast()
removeLast():
E
Defined in: list.ts:1867
Remove and return the tail value.
Returns
E
Remarks
Complexity: O(1)
Implementation of
reverseIterator()
reverseIterator():
Generator<E,void,unknown>
Defined in: list.ts:1970
Iterates elements from the most recently added to the earliest.
Returns
Generator<E, void, unknown>
Implementation of
set()
set(
index,e):boolean
Defined in: list.ts:1630
Replace the element at index.
Parameters
index
number
Position to update.
e
E
New value.
Returns
boolean
true when successful.
Implementation of
slice()
slice(
startIndex,endIndex):CyclicDoublyLinkedList<E>
Defined in: list.ts:1639
Take a slice using modulo arithmetic for wrap-around indices.
Parameters
startIndex
number
Beginning index (accepts negatives).
endIndex
number
Ending index.
Returns
CyclicDoublyLinkedList<E>
New list with copied range.
Remarks
Complexity: O(k) where k is slice length.
Implementation of
slice2()
slice2(
startIndex,endIndex):CyclicDoublyLinkedList<E>
Defined in: list.ts:1647
Variant of slice where the sign of endIndex decides direction.
Parameters
startIndex
number
endIndex
number
Returns
CyclicDoublyLinkedList<E>
New list containing copied range.
Remarks
Complexity: O(k)
Implementation of
some()
some(
predicate):boolean
Defined in: list.ts:1760
Test whether any element matches the predicate.
Parameters
predicate
(e) => boolean
Match callback.
Returns
boolean
true when at least one element matches.
Remarks
Complexity: O(n)
Implementation of
sort()
sort(
cmp?):void
Defined in: list.ts:1952
Sort the structure using the provided comparator.
Parameters
cmp?
Comparator<E>
Optional comparator; falls back to the internal one.
Returns
void
Implementation of
splice()
splice(
startIndex,deleteCount):CyclicDoublyLinkedList<E>
Defined in: list.ts:1702
Remove and return a consecutive range.
Parameters
startIndex
number
Start position.
deleteCount
number
Number of items to remove (negative => left).
Returns
CyclicDoublyLinkedList<E>
List containing removed elements.
Remarks
Complexity: O(n)