A bunch of data structures like linked list, stack, queue and others
$ npm i structures-for-data.ts
import {LinkedList, Queue, Stack } from 'structures-for-data.ts'
let linkedList = new LinkedList<>();
let queue = new Queue<>();
let stack = new Stack<>();
Table of Contents
[TOC]
Function name | Description |
---|---|
add (value: T, index: number) : void |
Adds an value at specified index |
addAllStartingAt (values: T[], index: number) : void |
Adds all elements from values at LinkedList start at given index |
addFirst (value: T) : void |
Adds an value at the beginning of the LinkedList |
addLast (value: T) : void |
Adds an value at the end of the LinkedList |
addFirstAll (values: T[]) : void |
Adds all elements from values at at the beginning of the LinkedList |
addLastAll (values: T[]) : void |
Adds all elements from values at at the end of the LinkedList |
clear() : void |
Removes all elements of LinkedList |
get(index: number) : T |
Returns element of index of the LinkedList |
getFirst() : T |
Returns the first element of the LinkedList |
getIndex (value: any) : number |
Returns index of value given of the LinkedList |
getLast() : T |
Returns the last element of the LinkedList |
remove (value: T) : boolean |
Returns an boolean indicating whether given value has been removed or not |
removeFirst() :boolean |
Returns an boolean indicating whether first element has been removed or not |
removeIndex (index: number) : boolean |
Returns an boolean indicating whether index of element given has been removed or not |
removeMultiple (startIndex: number, quantity: number):boolean |
Returns an boolean indicating whether given values has been removed or not |
removeLast() : boolean |
Returns an boolean indicating whether last element has been removed or not |
show() : void |
Prints all element of the LinkedList |
toArray(): T[] |
Converts the LinkedList into an array |
import {LinkedList } from 'structures-for-data.ts'
let linkedList = new LinkedList<>();
linkedList.add(2,6);
linkedList.addAllStartingAt([1,2,3,4], 3);
linkedList.addFirstAll([1,2,3,4]);
linkedList.addLastAll([1,2,3,4]);
linkedList.clear();
linkedList.get(4);
linkedList.getFirst();
linkedList.getIndex(80);
linkedList.getLast();
linkedList.remove(80);
linkedList.removeFirst();
linkedList.removeLast();
linkedList.removeIndex(4);
linkedList.removeMultiple(0,4)
linkedList.show()
linkedList.toArray();