@zimmed/prefab / Exports / LinkedList
Name | Type |
---|---|
T |
T |
N |
extends LNode <T > = LNode <T > |
-
LinkedList
- [iterator]
- _findNode
- add
- addNode
- append
- clear
- concat
- concatUnsafe
- cycle
- delete
- deleteNode
- entries
- filter
- find
- forEach
- has
- headNode
- insert
- insertNode
- join
- keys
- map
- new
- pop
- recycle
- reduce
- reverse
- shift
- slice
- tailNode
- toArray
- toArraySlice
- toJSON
- unshift
- values
• new LinkedList<T
, N
>(iterable?
, init?
)
Name | Type |
---|---|
T |
T |
N |
extends LNode <T > = LNode <T > |
Name | Type | Description |
---|---|---|
iterable? |
IterableIterator <T > | T [] |
Optional iterable with which to initialize the list |
init? |
object |
- |
• Protected
Optional
_head: N
• Protected
Optional
_tail: N
• get
head(): undefined
| T
Item at head of the list
undefined
| T
• get
tail(): undefined
| T
Item at tail of the list
undefined
| T
▸ [iterator](): IterableIterator
<T
>
IterableIterator
<T
>
▸ Private
_findNode(item
): undefined
| N
Name | Type |
---|---|
item |
T |
undefined
| N
▸ add(item
): LinkedList
<T
, N
>
Adds item to end of the list
Name | Type |
---|---|
item |
T |
LinkedList
<T
, N
>
▸ addNode(node
): LinkedList
<T
, N
>
Caution: Assumes node already has correct head and tail set Adds node to the end of the list
Name | Type |
---|---|
node |
N |
LinkedList
<T
, N
>
▸ append(item
): LinkedList
<T
, N
>
Adds item to end of the list
Name | Type |
---|---|
item |
T |
LinkedList
<T
, N
>
▸ clear(): void
Clears the list
void
▸ concat(...lists
): LinkedList
<T
, N
>
Concatenates the the lists into a new list
Name | Type |
---|---|
...lists |
readonly (T | LinkedList <T , N > | T [])[] |
LinkedList
<T
, N
>
▸ concatUnsafe(list
): LinkedList
<T
, N
>
appends the specified list directly onto the tail of the second list
Name | Type |
---|---|
list |
LinkedList <T , N > |
LinkedList
<T
, N
>
▸ cycle(): LinkedList
<T
, N
>
Moves element from end of list to the front
LinkedList
<T
, N
>
▸ delete(item
): boolean
Removes item from the list
Name | Type |
---|---|
item |
T |
boolean
▸ deleteNode(cur?
): boolean
Removes specified node from the list
Name | Type |
---|---|
cur? |
N |
boolean
▸ entries(): IterableIterator
<[T
, T
]>
Kind of pointless, but needed for parity with builtin Set object
IterableIterator
<[T
, T
]>
▸ filter(predicate
): T
[]
Uses predicate to return a new array of all matching items (same signature is Array.protoype.filter)
Name | Type |
---|---|
predicate |
Callback <T , LinkedList <T , N >, boolean , LinkedList <T , N >> |
T
[]
▸ filter<This
>(predicate
, thisArg
): T
[]
Name |
---|
This |
Name | Type |
---|---|
predicate |
Callback <T , This , boolean , LinkedList <T , N >> |
thisArg |
This |
T
[]
▸ find(predicate
): undefined
| T
Uses predicate to return first matching item or undefined if no matches (same signature as Array.prototype.find)
Name | Type |
---|---|
predicate |
Callback <T , LinkedList <T , N >, boolean , LinkedList <T , N >> |
undefined
| T
▸ find<This
>(predicate
, thisArg
): undefined
| T
Name |
---|
This |
Name | Type |
---|---|
predicate |
Callback <T , This , boolean , LinkedList <T , N >> |
thisArg |
This |
undefined
| T
▸ forEach(cb
): void
Operates on each element of the list in a callback method (same signature as Array.prototype.forEach)
Name | Type |
---|---|
cb |
Callback <T , LinkedList <T , N >, void , LinkedList <T , N >> |
void
▸ forEach<ThisArg
>(cb
, thisArg?
): void
Name |
---|
ThisArg |
Name | Type |
---|---|
cb |
Callback <T , ThisArg , void , LinkedList <T , N >> |
thisArg? |
ThisArg |
void
▸ has(item
): boolean
Careful! O(n) Checks to see if item exists in list
Name | Type |
---|---|
item |
T |
boolean
▸ headNode(node
): LinkedList
<T
, N
>
Caution: Assumes node is already part of linked list Moves node to the front of the list
Name | Type |
---|---|
node |
N |
LinkedList
<T
, N
>
▸ insert(item
): LinkedList
<T
, N
>
Adds item to front of the list
Name | Type |
---|---|
item |
T |
LinkedList
<T
, N
>
▸ insertNode(node
): LinkedList
<T
, N
>
Caution: Assumes node already has correct head and tail set Adds node to the front of the list
Name | Type |
---|---|
node |
N |
LinkedList
<T
, N
>
▸ join(separator?
): string
Joins list elements into one string (same signature as Array.prototype.join)
Name | Type |
---|---|
separator? |
string |
string
▸ keys(): IterableIterator
<T
>
Alias for values() method
IterableIterator
<T
>
▸ map<RT
>(cb
): RT
[]
Maps list items into new array (same signature as Array.prototype.map)
Name |
---|
RT |
Name | Type |
---|---|
cb |
Callback <T , LinkedList <T , N >, RT , LinkedList <T , N >> |
RT
[]
▸ map<RT
, This
>(cb
, thisArg
): RT
[]
Name |
---|
RT |
This |
Name | Type |
---|---|
cb |
Callback <T , This , RT , LinkedList <T , N >> |
thisArg |
This |
RT
[]
▸ new(iterable?
): LinkedList
<T
, N
>
Name | Type |
---|---|
iterable? |
IterableIterator <T > | T [] |
LinkedList
<T
, N
>
▸ pop(): undefined
| T
Removes and returns the last element of the list (or undefined if list is empty)
undefined
| T
▸ recycle(): LinkedList
<T
, N
>
Moves element from front of list to the end
LinkedList
<T
, N
>
▸ reduce<RT
>(cb
, initialValue
): RT
Reduces list into specified value (same signature as Array.prototype.reduce)
Name |
---|
RT |
Name | Type |
---|---|
cb |
Reducer <T , LinkedList <T , N >, RT , LinkedList <T , N >> |
initialValue |
RT |
RT
▸ reduce<RT
, This
>(cb
, initialValue
, thisArg?
): RT
Name |
---|
RT |
This |
Name | Type |
---|---|
cb |
Reducer <T , This , RT , LinkedList <T , N >> |
initialValue |
RT |
thisArg? |
This |
RT
▸ reverse(): IterableIterator
<T
>
Iterates through list items in reverse
IterableIterator
<T
>
▸ shift(): undefined
| T
Removes and returns the first element of the list (or undefined if list is empty)
undefined
| T
▸ slice(start?
, end?
): LinkedList
<T
, N
>
Creates a new slice of the linked list
Name | Type | Default value |
---|---|---|
start |
number |
0 |
end |
number |
Infinity |
LinkedList
<T
, N
>
▸ tailNode(node
): LinkedList
<T
, N
>
Caution: Assumes node is already part of linked list Moves node to the end of the list
Name | Type |
---|---|
node |
N |
LinkedList
<T
, N
>
▸ toArray(): T
[]
Converts list to native Array
T
[]
▸ toArraySlice(start?
, end?
): T
[]
Converts list to an array slice
Name | Type | Default value |
---|---|---|
start |
number |
0 |
end |
number |
Infinity |
T
[]
▸ toJSON(): T
[]
T
[]
▸ unshift(item
): LinkedList
<T
, N
>
Alias for insert
Name | Type |
---|---|
item |
T |
LinkedList
<T
, N
>
▸ values(): IterableIterator
<T
>
Iterates through list items
IterableIterator
<T
>