Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/easyts/container/list.ts>List

js library written with ts, use select and chan like golang in js.
Latest
class List
implements Container<T>
extends Basic<T>
import { List } from "https://deno.land/x/easyts@0.1.3/container/list.ts";

Doubly linked list. Refer to the golang standard library implementation

Constructors

new
List(opts?: Options<T>)

Properties

private
length_: number

record linked list length

private
root_: ListElement<T>

sentinel list element, only root, root.prev, and root.next are used

readonly
capacity: number

returns the capacity of the linked list

readonly
length: number

returns the length of the linked list

Methods

private
_insert(e: ListElement<T>, at: ListElement<T>)

insert inserts e after at, increments length

private
_move(e: ListElement<T>, at: ListElement<T>): boolean

move moves e to next to at and returns e.

remove removes e from its list, decrements length

back(): ListElement<T> | undefined

returns the last element of list l or nil if the list is empty.

clear(callback?: DeleteCallback<T>): void

clear the list

clone(callback?: CloneCallback<T>): List<T>

Create a full copy of the container

front(): ListElement<T> | undefined

returns the first element of list l or undefined if the list is empty.

insertAfter(v: T, mark: ListElement<T>): ListElement<T> | undefined

inserts a new element e with value v immediately after mark and returns e.

insertBefore(v: T, mark: ListElement<T>): ListElement<T> | undefined

inserts a new element e with value v immediately before mark and returns e.

iterator(reverse?: boolean): Iterator<T>

return js iterator

moveAfter(e: ListElement<T>, mark: ListElement<T>): boolean

moves element e to its new position after mark.

moveBefore(e: ListElement<T>, mark: ListElement<T>): boolean

moves element e to its new position before mark.

moveToBack(e: ListElement<T>): boolean

moves element e to the back of list.

moveToFront(e: ListElement<T>): boolean

moves element e to the front of list.

If the list is not empty delete the element at the back

If the list is not empty delete the element at the back

If the list is not empty delete the element at the front

If the list is not empty delete the element at the front

inserts a new element e with value v at the back of list and returns e.

pushBackList(vals: Iterable<T>, callback?: CloneCallback<T>)

inserts a copy of another container at the back of list.

inserts a new element e with value v at the front of list and returns e.

pushFrontList(vals: Iterable<T>, callback?: CloneCallback<T>)

inserts a copy of another container at the front of list l.

remove(e: ListElement<T>, callback?: DeleteCallback<T>): boolean

remove e from list if e is an element of list.