1.0.7 • Published 2 years ago

@simonlongstaff/linked-list v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Linked List

A TypeScript LinkedList data type implementation with a current node tracking function

Getters

getHead() 
getTail()
getCurrent()
getLenght()

List Manipulation

push(value: object)

Pushes a JSON object on to the bottom of the list

pop()

Removes the last node from the list

shift()

Removes the first node from the list

unshift(value: object)

Pushes a JSON object into the top of the list

insertAtIndex(value: object, index: number)

Pushes a JSON object at the index supplied

removeAtIndex(index: number)

Removes node at index

getAtIndex(index:number)

Returns the JSON of node at index

setAtIndex(value: object, index: number)

Replaces the JSON of node at index

reverse()

Reverses the order of the list

Current Node Tracking

By default, the current node will be set as the head of the list

setCurrent(index:number)

Set the current node as the node at index

next()
previous()

Sets the current node to the next or previous node in the list, does nothing if it is null

Output

toArray()
toString()

Return the values of all nodes in the list as an array or a stringified json

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago