Skip to content

Latest commit

 

History

History
709 lines (400 loc) · 14 KB

linkedlist.md

File metadata and controls

709 lines (400 loc) · 14 KB

dastal - v5.0.0 / LinkedList

Class: LinkedList<T>

A (circular) linked list implementation of the List interface.

Type parameters

Name
T

Implements

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new LinkedList<T>(elements?)

Instantiate the list.

Type parameters

Name
T

Parameters

Name Type Description
elements? Iterable<T> A set of elements to initialize the list with.

Defined in

src/list/linkedList.ts:22

Accessors

size

get size(): number

The number of elements in the collection.

Returns

number

Implementation of

List.size

Defined in

src/list/linkedList.ts:208

Methods

[iterator]

[iterator](): Iterator<T, any, undefined>

Receive an iterator through the list.

Note: Unexpected behavior can occur if the collection is modified during iteration.

Returns

Iterator<T, any, undefined>

An iterator through the list

Implementation of

List.[iterator]

Defined in

src/list/linkedList.ts:258


add

add(index, value): number

Add the element at the specified index.

Parameters

Name Type
index number
value T

Returns

number

Implementation of

List.add

Defined in

src/list/linkedList.ts:35


addAll

addAll(index, elements): number

Add elements at the specified index.

Parameters

Name Type
index number
elements Iterable<T>

Returns

number

Implementation of

List.addAll

Defined in

src/list/linkedList.ts:46


clear

clear(): void

Removes all elements.

Returns

void

Implementation of

List.clear

Defined in

src/list/linkedList.ts:55


concat

concat(...lists): LinkedList<T>

Combines the list with multiple iterables into a new list. Does not modify the existing list or inputs.

Parameters

Name Type
...lists Iterable<T>[]

Returns

LinkedList<T>

Implementation of

List.concat

Defined in

src/list/linkedList.ts:60


copyWithin

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

Parameters

Name Type
index number
min? number
max? number

Returns

LinkedList<T>

Implementation of

List.copyWithin

Defined in

src/list/linkedList.ts:68


fill

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.

Parameters

Name Type
element T
min? number
max? number

Returns

LinkedList<T>

Implementation of

List.fill

Defined in

src/list/linkedList.ts:111


get

get(index): undefined | T

Return the element at the specified index.

Parameters

Name Type
index number

Returns

undefined | T

Implementation of

List.get

Defined in

src/list/linkedList.ts:124


getSet

getSet(index, callback): undefined | T

Update the element at the specified index.

Parameters

Name Type
index number
callback (element: T) => T

Returns

undefined | T

Implementation of

List.getSet

Defined in

src/list/linkedList.ts:131


pop

pop(): undefined | T

Retrieves and removes the end of the list.

Returns

undefined | T

Implementation of

List.pop

Defined in

src/list/linkedList.ts:141


push

push(value): number

Inserts the specified value into the end of the list

Parameters

Name Type
value T

Returns

number

Implementation of

List.push

Defined in

src/list/linkedList.ts:152


remove

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.

Parameters

Name Type
index number

Returns

undefined | T

Implementation of

List.remove

Defined in

src/list/linkedList.ts:159


reverse

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.

Parameters

Name Type
min? number
max? number

Returns

LinkedList<T>

Implementation of

List.reverse

Defined in

src/list/linkedList.ts:172


set

set(index, element): undefined | T

Update the element at the specified index.

Parameters

Name Type
index number
element T

Returns

undefined | T

Implementation of

List.set

Defined in

src/list/linkedList.ts:194


shift

shift(): undefined | T

Retrieves and removes the first element in the list.

Returns

undefined | T

Implementation of

List.shift

Defined in

src/list/linkedList.ts:204


slice

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.

Parameters

Name Type
min? number
max? number

Returns

LinkedList<T>

Implementation of

List.slice

Defined in

src/list/linkedList.ts:212


sort

sort(compareFn): LinkedList<T>

Sorts the elements in place.

Parameters

Name Type
compareFn CompareFn<T>

Returns

LinkedList<T>

Implementation of

List.sort

Defined in

src/list/linkedList.ts:243


splice

splice(start?, count?, elements?): List<T>

Removes elements from the list and optionally inserts new elements in their place. Returns any deleted elements.

Parameters

Name Type
start? number
count? number
elements? Iterable<T>

Returns

List<T>

Implementation of

List.splice

Defined in

src/list/linkedList.ts:216


unshift

unshift(value): number

Inserts the specified value into the front of the list

Parameters

Name Type
value T

Returns

number

Implementation of

List.unshift

Defined in

src/list/linkedList.ts:264


update

update(callback): LinkedList<T>

Update the elements of the list

Parameters

Name Type
callback (element: T, index: number) => T

Returns

LinkedList<T>

Implementation of

List.update

Defined in

src/list/linkedList.ts:268

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.

Parameters

Name Type
min undefined | number
callback (element: T, index: number) => T

Returns

LinkedList<T>

Implementation of

List.update

Defined in

src/list/linkedList.ts:269

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.

Parameters

Name Type
min undefined | number
max undefined | number
callback (element: T, index: number) => T

Returns

LinkedList<T>

Implementation of

List.update

Defined in

src/list/linkedList.ts:270


view

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.

Parameters

Name Type
min? number
max? number

Returns

Iterable<T>

Implementation of

List.view

Defined in

src/list/linkedList.ts:301