Skip to content

Typed API (TypeDoc)


Typed API (TypeDoc) / ILinkedList

Interface: ILinkedList<E>

Defined in: list.ts:142

Since

2.0.0

Extends

Type Parameters

E

E

Value type.

Properties

comparator

comparator: Comparator<E>

Defined in: index.ts:142

Comparator used for equality/sort checks.

Inherited from

IList.comparator


first

first: Node<E>

Defined in: list.ts:146

Head node reference.


last

last: Node<E>

Defined in: list.ts:150

Tail node reference.


size

size: number

Defined in: index.ts:146

Current element count.

Inherited from

IList.size

Methods

add()

add(element): void

Defined in: index.ts:153

Append an element.

Parameters

element

E

Returns

void

Remarks

Complexity: Amortized O(1) unless stated otherwise.

Inherited from

IList.add


addAll()

addAll(collection): void

Defined in: list.ts:98

Append every value from an iterable.

Parameters

collection

Iterable<E>

Source iterable.

Returns

void

Remarks

Complexity: O(n)

Inherited from

IList.addAll


addFirst()

addFirst(element): void

Defined in: list.ts:164

Insert at the beginning.

Parameters

element

E

Returns

void

Remarks

Complexity: O(1)


addLast()

addLast(element): void

Defined in: list.ts:171

Insert at the end.

Parameters

element

E

Returns

void

Remarks

Complexity: O(1)


clear()

clear(): void

Defined in: index.ts:178

Remove all entries.

Returns

void

Remarks

Complexity: O(n)

Inherited from

IList.clear


contains()

contains(element): boolean

Defined in: index.ts:192

Test membership using the comparator when available.

Parameters

element

E

Returns

boolean

Remarks

Complexity: O(n) worst case

Inherited from

IList.contains


equals()

equals(otherList): boolean

Defined in: list.ts:124

Compare equality value-by-value using the comparator.

Parameters

otherList

IList<E>

List to compare.

Returns

boolean

true when lengths match and all elements compare equal.

Inherited from

IList.equals


every()

every(predicate): boolean

Defined in: list.ts:51

Test whether every element matches the predicate.

Parameters

predicate

(element) => boolean

Match callback.

Returns

boolean

true when all elements satisfy the predicate.

Remarks

Complexity: O(n)

Inherited from

IList.every


filter()

filter(predicate): IList<E>

Defined in: list.ts:42

Create a list containing values that satisfy the predicate.

Parameters

predicate

(element) => boolean

Filter callback.

Returns

IList<E>

Filtered list.

Remarks

Complexity: O(n)

Inherited from

IList.filter


get()

get(index): E

Defined in: list.ts:107

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.

Inherited from

IList.get


getFirst()

getFirst(): E

Defined in: list.ts:178

Read the first element.

Returns

E

Throws

When empty.


getLast()

getLast(): E

Defined in: list.ts:183

Read the last element.

Returns

E


getNode()

getNode(index): Node<E>

Defined in: list.ts:157

Retrieve the internal node at index.

Parameters

index

number

Returns

Node<E>

Remarks

Complexity: O(n)


indexOf()

indexOf(element, startIndex?): number

Defined in: list.ts:134

Locate the first matching element starting at startIndex.

Parameters

element

E

Needle value.

startIndex?

number

Optional search start.

Returns

number

Index or -1.

Remarks

Complexity: O(n)

Inherited from

IList.indexOf


isEmpty()

isEmpty(): boolean

Defined in: index.ts:185

Check for emptiness.

Returns

boolean

true when size === 0.

Inherited from

IList.isEmpty


map()

map<V>(fn): IList<V>

Defined in: list.ts:22

Transform each element.

Type Parameters

V

V

Result type.

Parameters

fn

(element) => V

Mapper invoked per element.

Returns

IList<V>

New list containing mapped values.

Remarks

Complexity: O(n)

Inherited from

IList.map


reduce()

reduce<V>(fn, initialValue?): V

Defined in: list.ts:33

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)

Inherited from

IList.reduce


remove()

remove(e, isIndex?): number | E

Defined in: index.ts:171

Remove by value or index.

Parameters

e

Element or index.

number | E

isIndex?

boolean

When true, treat e as index.

Returns

number | E

Removed element or index of removal.

Throws

If neither argument nor existing comparator are set.

Remarks

Complexity: O(n) worst case.

Inherited from

IList.remove


removeFirst()

removeFirst(): E

Defined in: list.ts:190

Remove and return the head value.

Returns

E

Remarks

Complexity: O(1)


removeLast()

removeLast(): E

Defined in: list.ts:197

Remove and return the tail value.

Returns

E

Remarks

Complexity: O(1)


reverseIterator()

reverseIterator(): Generator<E>

Defined in: list.ts:139

Iterate backwards.

Returns

Generator<E>

Inherited from

IList.reverseIterator


set()

set(index, element): boolean

Defined in: list.ts:116

Replace the element at index.

Parameters

index

number

Position to update.

element

New value.

E | null

Returns

boolean

true when successful.

Inherited from

IList.set


slice()

slice(startIndex, endIndex): IList<E>

Defined in: list.ts:70

Take a slice using modulo arithmetic for wrap-around indices.

Parameters

startIndex

number

Beginning index (accepts negatives).

endIndex

number

Ending index.

Returns

IList<E>

New list with copied range.

Remarks

Complexity: O(k) where k is slice length.

Inherited from

IList.slice


slice2()

slice2(startIndex, endIndex): IList<E>

Defined in: list.ts:78

Variant of slice where the sign of endIndex decides direction.

Parameters

startIndex

number

endIndex

number

Returns

IList<E>

New list containing copied range.

Remarks

Complexity: O(k)

Inherited from

IList.slice2


some()

some(predicate): boolean

Defined in: list.ts:60

Test whether any element matches the predicate.

Parameters

predicate

(element) => boolean

Match callback.

Returns

boolean

true when at least one element matches.

Remarks

Complexity: O(n)

Inherited from

IList.some


sort()

sort(cmp?): void

Defined in: sort/index.ts:18

Sort the structure using the provided comparator.

Parameters

cmp?

Comparator<E>

Optional comparator; falls back to the internal one.

Returns

void

Inherited from

IList.sort


splice()

splice(startIndex, deleteCount): IList<E>

Defined in: list.ts:88

Remove and return a consecutive range.

Parameters

startIndex

number

Start position.

deleteCount

number

Number of items to remove (negative => left).

Returns

IList<E>

List containing removed elements.

Remarks

Complexity: O(n)

Inherited from

IList.splice

Built with VitePress – Released under the MIT License.