Socket
Socket
Sign inDemoInstall

@mkhstar/datastructures

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mkhstar/datastructures - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

60

dist/ds/LinkedList.d.ts

@@ -5,2 +5,7 @@ interface TestLinkedListElement<E> {

export declare class LinkedList<E> {
/**
* Constructs a new linked list
* @constructor
* @param {Array<E>} initialItems - The initial items in the linked list
*/
constructor(...initialItems: Array<E>);

@@ -11,18 +16,73 @@ private length;

private list;
/**
* @return {number} The size of the linked list
*/
size(): number;
/**
* @return {E | null} The first element of the linked list
*/
getFirstElement(): E | null;
/**
* @return {E | null} The last element of the linked list
*/
getLastElement(): E | null;
[Symbol.iterator](): Generator<E, void, unknown>;
/**
*
* @param {number} index The index to look up
* @return {E | null}
*/
indexOf(index: number): E | null;
/**
* @description Removes an element at the specified index, returns true if an element was removed and false otherwise
* @param {number} removeAt The index of the element to remove
* @return boolean
*/
removeAt(index: number): boolean;
/**
* @description Removes all elements that are equal to the element specified
* @param {E} element The element to look up
*/
removeElements(element: E): void;
/**
* @description Removes all elements that satisfy the test function
* @param {TestLinkedListElement} test
*/
removeElementsWhere(test: TestLinkedListElement<E>): void;
/**
* @description Removes an element that is equal to the element specified
* @param {E} element
*/
removeElement(element: E): boolean;
/**
* @description Remove an element that satisfy the test function
* @param {TestLinkedListElement} test
*/
removeElementWhere(test: TestLinkedListElement<E>): boolean;
/**
* @description inserts an element at the specified index
* @param {number} index
* @param {E} element
*/
insertAt(index: number, element: E): boolean;
/**
* @description appends the elements at the tail (end) of the linked list
* @param {Array<E>} items
*/
add(...items: Array<E>): void;
/**
* @description Adds an element to the linked list at the head
* @param {E} item
*/
addFirst(item: E): void;
/**
* @description Adds an element to the tail of the linked list
* @param {E} item
*/
addLast(item: E): void;
/**
* @description Clears the linked list
*/
clear(): void;
}
export {};

@@ -63,2 +63,7 @@ "use strict";

var LinkedList = /** @class */ (function () {
/**
* Constructs a new linked list
* @constructor
* @param {Array<E>} initialItems - The initial items in the linked list
*/
function LinkedList() {

@@ -75,5 +80,11 @@ var initialItems = [];

}
/**
* @return {number} The size of the linked list
*/
LinkedList.prototype.size = function () {
return this.length;
};
/**
* @return {E | null} The first element of the linked list
*/
LinkedList.prototype.getFirstElement = function () {

@@ -83,2 +94,5 @@ var _a;

};
/**
* @return {E | null} The last element of the linked list
*/
LinkedList.prototype.getLastElement = function () {

@@ -106,2 +120,7 @@ var _a;

};
/**
*
* @param {number} index The index to look up
* @return {E | null}
*/
LinkedList.prototype.indexOf = function (index) {

@@ -127,2 +146,7 @@ var e_1, _a;

};
/**
* @description Removes an element at the specified index, returns true if an element was removed and false otherwise
* @param {number} removeAt The index of the element to remove
* @return boolean
*/
LinkedList.prototype.removeAt = function (index) {

@@ -157,2 +181,6 @@ if (index < 0 || index + 1 > this.length)

};
/**
* @description Removes all elements that are equal to the element specified
* @param {E} element The element to look up
*/
LinkedList.prototype.removeElements = function (element) {

@@ -180,2 +208,6 @@ if (!this.length)

};
/**
* @description Removes all elements that satisfy the test function
* @param {TestLinkedListElement} test
*/
LinkedList.prototype.removeElementsWhere = function (test) {

@@ -203,2 +235,6 @@ if (!this.length)

};
/**
* @description Removes an element that is equal to the element specified
* @param {E} element
*/
LinkedList.prototype.removeElement = function (element) {

@@ -228,2 +264,6 @@ if (!this.length)

};
/**
* @description Remove an element that satisfy the test function
* @param {TestLinkedListElement} test
*/
LinkedList.prototype.removeElementWhere = function (test) {

@@ -253,2 +293,7 @@ if (!this.length)

};
/**
* @description inserts an element at the specified index
* @param {number} index
* @param {E} element
*/
LinkedList.prototype.insertAt = function (index, element) {

@@ -282,2 +327,6 @@ if (index < 0 || index + 1 > this.length)

};
/**
* @description appends the elements at the tail (end) of the linked list
* @param {Array<E>} items
*/
LinkedList.prototype.add = function () {

@@ -309,2 +358,6 @@ var e_2, _a;

};
/**
* @description Adds an element to the linked list at the head
* @param {E} item
*/
LinkedList.prototype.addFirst = function (item) {

@@ -318,2 +371,6 @@ if (!this.list) {

};
/**
* @description Adds an element to the tail of the linked list
* @param {E} item
*/
LinkedList.prototype.addLast = function (item) {

@@ -327,2 +384,5 @@ if (!this.last) {

};
/**
* @description Clears the linked list
*/
LinkedList.prototype.clear = function () {

@@ -329,0 +389,0 @@ this.first = this.last = this.list = null;

@@ -6,8 +6,29 @@ export declare class Queue<E> {

constructor(capacity?: number);
/**
* @description Is the Queue empty
* @return {boolean}
*/
get isEmpty(): boolean;
/**
* @description Is the Queue full
* @return {boolean}
*/
get isFull(): boolean;
private get nextTailIndex();
private get nextHeadIndex();
/**
* @description Add an element to the queue
* @param {E} element
*/
enqueue(element: E): void;
/**
* @description Remove an element from the queue and return it
* @return {E | null}
*/
dequeue(): E | null;
/**
* @description Returns the element at the head of the queue
* @return {E | null}
*/
peek(): E | null;
}

27

dist/ds/Queue.js

@@ -12,2 +12,6 @@ "use strict";

Object.defineProperty(Queue.prototype, "isEmpty", {
/**
* @description Is the Queue empty
* @return {boolean}
*/
get: function () {

@@ -20,4 +24,8 @@ return this.head === -1 && this.tail === -1;

Object.defineProperty(Queue.prototype, "isFull", {
/**
* @description Is the Queue full
* @return {boolean}
*/
get: function () {
return this.head !== -1 && this.tail !== -1 && this.nextTailIndex === this.head;
return (this.head !== -1 && this.tail !== -1 && this.nextTailIndex === this.head);
},

@@ -45,2 +53,6 @@ enumerable: false,

});
/**
* @description Add an element to the queue
* @param {E} element
*/
Queue.prototype.enqueue = function (element) {

@@ -55,2 +67,6 @@ if (this.isEmpty)

};
/**
* @description Remove an element from the queue and return it
* @return {E | null}
*/
Queue.prototype.dequeue = function () {

@@ -68,4 +84,13 @@ if (this.isEmpty)

};
/**
* @description Returns the element at the head of the queue
* @return {E | null}
*/
Queue.prototype.peek = function () {
if (this.isEmpty)
return null;
return this.list[this.head];
};
return Queue;
}());
exports.Queue = Queue;

@@ -5,6 +5,22 @@ export declare class Stack<E> {

constructor(capacity?: number);
/**
* @description Push an element to the stack
* @param {E} element
*/
push(element: E): void;
/**
* @description Is the stack empty?
* @return {boolean}
*/
isEmpty(): boolean;
/**
* @description Removes an element from the top of the stack and return it
* @return {E | null} element
*/
pop(): E | null;
/**
* @description Returns the element at the top of the stack
* @return {E | null} element
*/
peek(): E | null;
}

@@ -10,8 +10,20 @@ "use strict";

}
/**
* @description Push an element to the stack
* @param {E} element
*/
Stack.prototype.push = function (element) {
this.list[this.length++] = element;
};
/**
* @description Is the stack empty?
* @return {boolean}
*/
Stack.prototype.isEmpty = function () {
return !!this.length;
};
/**
* @description Removes an element from the top of the stack and return it
* @return {E | null} element
*/
Stack.prototype.pop = function () {

@@ -22,2 +34,6 @@ if (!this.length)

};
/**
* @description Returns the element at the top of the stack
* @return {E | null} element
*/
Stack.prototype.peek = function () {

@@ -24,0 +40,0 @@ return this.length ? this.list[this.length - 1] : null;

6

package.json
{
"name": "@mkhstar/datastructures",
"public": true,
"version": "1.0.0",
"version": "1.0.1",
"description": "Data Structures for Javascript",
"main": "dist/index.js",
"scripts": {
"start": "tsc --watch"
"start": "tsc --watch",
"build": "tsc",
"prepublish": "tsc"
},

@@ -10,0 +12,0 @@ "author": "Kusi Musah Hussein",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc