jex-dll
v1.1.0
Published
a doubly linked list
Downloads
3
Readme
jex-dll
a doubly-linked list
import DLL from 'jex-dll'
const list = new DLL()
Append to the list.
list.push('hello')
list.push('kitty')
list.nodes
[
{
prev: null,
value: 'hello',
next: 'kitty',
},
{
prev: 'hello',
value: 'kitty',
next: null,
},
]
Prepend to the list.
list.unshift('banana')
list.nodes
[
{
prev: null,
value: 'banana',
next: 'hello',
},
{
prev: 'banana',
value: 'hello',
next: 'kitty',
},
{
prev: 'hello',
value: 'kitty',
next: null,
},
]
Remove stuff by index.
list.remove(0)
list.nodes
[
{
prev: null,
value: 'hello',
next: 'kitty',
},
{
prev: 'hello',
value: 'kitty',
next: null,
},
]
Insert at index.
list.insert(1, 'apples')
list.nodes
[
{
prev: null,
value: 'hello',
next: 'apples',
},
{
prev: 'hello',
value: 'apples',
next: 'kitty',
},
{
prev: 'apples',
value: 'kitty',
next: null,
},
]
Move stuff from one index to another.
list.move(0, 2)
list.nodes
[
{
prev: null,
value: 'apples',
next: 'kitty',
},
{
prev: 'apples',
value: 'kitty',
next: 'hello',
},
{
prev: 'kitty',
value: 'hello',
next: null,
},
])