Skip to content

Latest commit

 

History

History
709 lines (400 loc) · 13.9 KB

arraylist.md

File metadata and controls

709 lines (400 loc) · 13.9 KB

dastal - v5.0.0 / ArrayList

Class: ArrayList<T>

An implementation of the List interface using an array

Type parameters

Name
T

Implements

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new ArrayList<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/arrayList.ts:13

Accessors

size

get size(): number

The number of elements in the collection.

Returns

number

Implementation of

List.size

Defined in

src/list/arrayList.ts:113

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/arrayList.ts:136


add

add(index, element): number

Add the element at the specified index.

Parameters

Name Type
index number
element T

Returns

number

Implementation of

List.add

Defined in

src/list/arrayList.ts:23


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/arrayList.ts:30


clear

clear(): void

Removes all elements.

Returns

void

Implementation of

List.clear

Defined in

src/list/arrayList.ts:37


concat

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

ArrayList<T>

Implementation of

List.concat

Defined in

src/list/arrayList.ts:41


copyWithin

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

ArrayList<T>

Implementation of

List.copyWithin

Defined in

src/list/arrayList.ts:49


fill

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

ArrayList<T>

Implementation of

List.fill

Defined in

src/list/arrayList.ts:57


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/arrayList.ts:64


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/arrayList.ts:68


pop

pop(): undefined | T

Retrieves and removes the end of the list.

Returns

undefined | T

Implementation of

List.pop

Defined in

src/list/arrayList.ts:77


push

push(element): number

Inserts the specified value into the end of the list

Parameters

Name Type
element T

Returns

number

Implementation of

List.push

Defined in

src/list/arrayList.ts:81


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/arrayList.ts:85


reverse

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

ArrayList<T>

Implementation of

List.reverse

Defined in

src/list/arrayList.ts:89


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/arrayList.ts:100


shift

shift(): undefined | T

Retrieves and removes the first element in the list.

Returns

undefined | T

Implementation of

List.shift

Defined in

src/list/arrayList.ts:109


slice

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

ArrayList<T>

Implementation of

List.slice

Defined in

src/list/arrayList.ts:117


sort

sort(compareFn): ArrayList<T>

Sorts the elements in place.

Parameters

Name Type
compareFn CompareFn<T>

Returns

ArrayList<T>

Implementation of

List.sort

Defined in

src/list/arrayList.ts:125


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/arrayList.ts:121


unshift

unshift(element): number

Inserts the specified value into the front of the list

Parameters

Name Type
element T

Returns

number

Implementation of

List.unshift

Defined in

src/list/arrayList.ts:140


update

update(callback): ArrayList<T>

Update the elements of the list

Parameters

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

Returns

ArrayList<T>

Implementation of

List.update

Defined in

src/list/arrayList.ts:144

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

ArrayList<T>

Implementation of

List.update

Defined in

src/list/arrayList.ts:145

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

ArrayList<T>

Implementation of

List.update

Defined in

src/list/arrayList.ts:146


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/arrayList.ts:174