Skip to main content
The Deno 2 Release Candidate is here
Learn more
class LinkedList
import { LinkedList } from "https://deno.land/x/sptaki@1.2.0/utils/collections/mod.ts";

Constructors

new
LinkedList()

Properties

private
_length
private
optional
head
private
writeonly
length
private
optional
tail
readonly
length: number

Methods

append(value: T): void

Adds an element to the end of the list.

entries(): IterableIterator<[number, T]>

Returns an iterable of index, value pairs for every entry in the list.

get(idx: number): T

Finds the element from the list at the given index and returns it's value.

Returns the first element's value.

Returns the last element's value.

insertAt(value: T, idx: number): void

Adds an element at the given index to the list.

pop(): T

Removes the last element from the list and returns it's value. If the list is empty, undefined is returned and the list is not modified.

prepend(value: T): void

Adds an element to the start of the list.

remove(value: T): T

Finds and removes the first element from a list that has a value equal to the given value, returns it's value if it successfully removed it.

removeAt(idx: number): T

Removes the element from the list at the given index and returns it's value.

shift(): T

Removes the first element from the list and returns it's value. If the list is empty, undefined is returned and the list is not modified.

values(): IterableIterator<T>

Returns an iterable of values in the list.