Function
Static Public Summary | ||
public |
Node(value: any) Base node class. |
|
public |
Concatenate two input lists. |
|
public |
Return an empty list. |
|
public |
Creates a list from an input iterable. |
|
public |
Generator of nodes in list in order. |
|
public |
Compute the length of a list (can be empty). |
|
public |
Removes last Node from a list. |
|
public |
Push value to list. |
|
public |
rotate_left(x: Node, n: number): Node Do nothing if x is empty or n is zero. |
|
public |
rotate_right(x: Node, n: number): Node Do nothing if x is empty or n is zero. |
|
public |
Removes first Node from a list. |
|
public |
Unshift value to list. |
|
public |
Generator of nodes in list in order. |
Static Private Summary | ||
private |
Optimization of _concat when |
|
private |
Concatenate two input lists. |
|
private |
Generator of nodes in list in order. |
|
private |
* _iter_fast(first: Node): IterableIterator<Node> Generator of nodes in list in order. |
|
private |
Compute the length of a non-empty list. |
|
private |
Removes last Node from a non-empty list. |
|
private |
Removes input Node from its list. |
|
private |
_rotate_left(x: Node, n: number): Node Rotate list to the left n steps. |
|
private |
_rotate_right(x: Node, n: number): Node Rotate list to the right n steps. |
|
private |
Removes first Node from a non-empty list. |
Static Public
public Node(value: any) source
import Node from '@data-structure-algebra/circularly-linked-list/src/Node.js'
Base node class.
Params:
Name | Type | Attribute | Description |
value | any | The value to hold. |
public concat(x: Node, y: Node): Node source
import concat from '@data-structure-algebra/circularly-linked-list/src/concat.js'
Concatenate two input lists.
public empty(): Node source
import empty from '@data-structure-algebra/circularly-linked-list/src/empty.js'
Return an empty list.
public from(iterable: Iterable): Node source
import from from '@data-structure-algebra/circularly-linked-list/src/from.js'
Creates a list from an input iterable.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
public * iter(first: Node): IterableIterator<Node> source
import iter from '@data-structure-algebra/circularly-linked-list/src/iter.js'
Generator of nodes in list in order.
Params:
Name | Type | Attribute | Description |
first | Node | First node of the list (can be null). |
public len(x: Node): number source
import len from '@data-structure-algebra/circularly-linked-list/src/len.js'
Compute the length of a list (can be empty).
Params:
Name | Type | Attribute | Description |
x | Node | First node of the input list (can be null). |
public pop(x: Node): [Node, Node] source
import pop from '@data-structure-algebra/circularly-linked-list/src/pop.js'
Removes last Node from a list. Throws if input list is empty.
Params:
Name | Type | Attribute | Description |
x | Node | First node. |
Return:
[Node, Node] | New list (possibly null) and removed node. |
public push(x: Node, value: any): Node source
import push from '@data-structure-algebra/circularly-linked-list/src/push.js'
Push value to list.
Params:
Name | Type | Attribute | Description |
x | Node | First node of first input list (can be null). |
|
value | any | Value to push. |
public rotate_left(x: Node, n: number): Node source
import rotate_left from '@data-structure-algebra/circularly-linked-list/src/rotate_left.js'
Do nothing if x is empty or n is zero. Rotate left n steps if n is positive. Rotate right n steps if n is negative.
public rotate_right(x: Node, n: number): Node source
import rotate_right from '@data-structure-algebra/circularly-linked-list/src/rotate_right.js'
Do nothing if x is empty or n is zero. Rotate right n steps if n is positive. Rotate left n steps if n is negative.
public shift(x: Node): [Node, Node] source
import shift from '@data-structure-algebra/circularly-linked-list/src/shift.js'
Removes first Node from a list. Throws if input list is empty.
Params:
Name | Type | Attribute | Description |
x | Node | First node . |
Return:
[Node, Node] | New list (possibly null) and removed node. |
public unshift(x: Node, value: Object): Node source
import unshift from '@data-structure-algebra/circularly-linked-list/src/unshift.js'
Unshift value to list.
public * values(first: Node): IterableIterator<any> source
import values from '@data-structure-algebra/circularly-linked-list/src/values.js'
Generator of nodes in list in order.
Params:
Name | Type | Attribute | Description |
first | Node | First node of the list (can be null). |
Return:
IterableIterator<any> |
Static Private
private _append(a: Node, x: Node) source
import _append from '@data-structure-algebra/circularly-linked-list/src/_append.js'
Optimization of _concat when x
contains a single element.
Works even if x
has dangling pointers x.next
and x.prev
.
private _concat(x: Node, y: Node) source
import _concat from '@data-structure-algebra/circularly-linked-list/src/_concat.js'
Concatenate two input lists.
private * _iter(first: Node): IterableIterator<Node> source
import _iter from '@data-structure-algebra/circularly-linked-list/src/_iter.js'
Generator of nodes in list in order. You are allowed to edit the current node.
/!\ Modifying the next pointer of the current node will NOT change which node comes next in the iteration.
Params:
Name | Type | Attribute | Description |
first | Node | First node of the list. |
private * _iter_fast(first: Node): IterableIterator<Node> source
import _iter_fast from '@data-structure-algebra/circularly-linked-list/src/_iter_fast.js'
Generator of nodes in list in order. The list cannot be empty. You should not modify the current node's next pointer unless you know what you are doing.
/!\ Modifying the next pointer of the current node will change which node comes next in the iteration.
Params:
Name | Type | Attribute | Description |
first | Node | First node of the list. |
private _len(x: Node): number source
import _len from '@data-structure-algebra/circularly-linked-list/src/_len.js'
Compute the length of a non-empty list.
Params:
Name | Type | Attribute | Description |
x | Node | First node of the input list. |
private _pop(x: Node): Node source
import _pop from '@data-structure-algebra/circularly-linked-list/src/_pop.js'
Removes last Node from a non-empty list.
Params:
Name | Type | Attribute | Description |
x | Node | First node (not null). |
private _remove(x: Node) source
import _remove from '@data-structure-algebra/circularly-linked-list/src/_remove.js'
Removes input Node from its list.
/!\ Pointers in the extracted node are left unchanged.
/!\ x
will have dangling pointers after removal if not single element.
Params:
Name | Type | Attribute | Description |
x | Node | Node to remove. |
private _rotate_left(x: Node, n: number): Node source
import _rotate_left from '@data-structure-algebra/circularly-linked-list/src/_rotate_left.js'
Rotate list to the left n steps. The parameter n must be positive.
private _rotate_right(x: Node, n: number): Node source
import _rotate_right from '@data-structure-algebra/circularly-linked-list/src/_rotate_right.js'
Rotate list to the right n steps. The parameter n must be positive.