Skip to content

Latest commit

 

History

History
711 lines (401 loc) · 14.8 KB

doublylinkedlist.md

File metadata and controls

711 lines (401 loc) · 14.8 KB

dastal - v5.0.0 / DoublyLinkedList

Class: DoublyLinkedList<T>

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

Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.

Type parameters

Name
T

Implements

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new DoublyLinkedList<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/doublyLinkedList.ts:20

Accessors

size

get size(): number

The number of elements in the collection.

Returns

number

Implementation of

List.size

Defined in

src/list/doublyLinkedList.ts:201

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/doublyLinkedList.ts:250


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/doublyLinkedList.ts:33


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/doublyLinkedList.ts:44


clear

clear(): void

Removes all elements.

Returns

void

Implementation of

List.clear

Defined in

src/list/doublyLinkedList.ts:51


concat

concat(...lists): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.concat

Defined in

src/list/doublyLinkedList.ts:56


copyWithin

copyWithin(index, min?, max?): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.copyWithin

Defined in

src/list/doublyLinkedList.ts:64


fill

fill(element, min?, max?): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.fill

Defined in

src/list/doublyLinkedList.ts:102


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/doublyLinkedList.ts:115


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/doublyLinkedList.ts:119


pop

pop(): undefined | T

Retrieves and removes the end of the list.

Returns

undefined | T

Implementation of

List.pop

Defined in

src/list/doublyLinkedList.ts:129


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/doublyLinkedList.ts:140


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/doublyLinkedList.ts:147


reverse

reverse(min?, max?): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.reverse

Defined in

src/list/doublyLinkedList.ts:158


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/doublyLinkedList.ts:180


shift

shift(): undefined | T

Retrieves and removes the first element in the list.

Returns

undefined | T

Implementation of

List.shift

Defined in

src/list/doublyLinkedList.ts:190


slice

slice(min?, max?): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.slice

Defined in

src/list/doublyLinkedList.ts:205


sort

sort(compareFn): DoublyLinkedList<T>

Sorts the elements in place.

Parameters

Name Type
compareFn CompareFn<T>

Returns

DoublyLinkedList<T>

Implementation of

List.sort

Defined in

src/list/doublyLinkedList.ts:235


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/doublyLinkedList.ts:209


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/doublyLinkedList.ts:256


update

update(callback): DoublyLinkedList<T>

Update the elements of the list

Parameters

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

Returns

DoublyLinkedList<T>

Implementation of

List.update

Defined in

src/list/doublyLinkedList.ts:263

update(min, callback): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.update

Defined in

src/list/doublyLinkedList.ts:264

update(min, max, callback): DoublyLinkedList<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

DoublyLinkedList<T>

Implementation of

List.update

Defined in

src/list/doublyLinkedList.ts:265


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/doublyLinkedList.ts:296