0.1.0 • Published 3 years ago

@vocaltech/data-structures v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Data structures using Typescript

Queues

Usage with generics:

// constructor
let q = new Queue<string>("v", "o")

// enqueue 1 string and returns the size of queue
q.enqueue("c"); // returns 3

// returns the head of the queue (without dequeuing)
q.peek(); // returns "v"

// returns the size of the queue
queue.size(); // returns 3

// dequeue
queue.dequeue(); // returns "v"

Stacks

Usage with generics:

// constructor
const stack = new Stack<string>("c", "b", "a")

// push 1 string and returns the size of stack
stack.push("d"); // returns 4

// returns the top of the stack (without removing)
stack.top(); // returns "d"

// returns the size of the stack
stack.size(); // returns 4

// remove the top of the stack
stack.pop(); // returns "d"
0.1.0

3 years ago

1.0.0

3 years ago

0.0.1

3 years ago