Socket
Socket
Sign inDemoInstall

data-structure-typed

Package Overview
Dependencies
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-structure-typed - npm Package Compare versions

Comparing version 1.15.1 to 1.15.2

src/assets/overview-diagram-of-data-structures.png

60

dist/data-structures/binary-tree/binary-tree.d.ts

@@ -25,4 +25,27 @@ /**

export declare class BinaryTreeNode<T> {
constructor(id: BinaryTreeNodeId, val: T, count?: number);
protected _id: BinaryTreeNodeId;
get id(): BinaryTreeNodeId;
set id(v: BinaryTreeNodeId);
protected _val: T;
get val(): T;
set val(v: T);
protected _left?: BinaryTreeNode<T> | null;
get left(): BinaryTreeNode<T> | null | undefined;
set left(v: BinaryTreeNode<T> | null | undefined);
protected _right?: BinaryTreeNode<T> | null;
get right(): BinaryTreeNode<T> | null | undefined;
set right(v: BinaryTreeNode<T> | null | undefined);
protected _parent: BinaryTreeNode<T> | null | undefined;
get parent(): BinaryTreeNode<T> | null | undefined;
set parent(v: BinaryTreeNode<T> | null | undefined);
protected _familyPosition: FamilyPosition;
get familyPosition(): FamilyPosition;
set familyPosition(v: FamilyPosition);
protected _count: number;
get count(): number;
set count(v: number);
protected _height: number;
get height(): number;
set height(v: number);
/**

@@ -32,5 +55,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getId(): BinaryTreeNodeId;
set id(v: BinaryTreeNodeId);
protected _val: T;
get val(): T;
/**

@@ -40,5 +60,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getVal(): T;
set val(v: T);
protected _left?: BinaryTreeNode<T> | null;
get left(): BinaryTreeNode<T> | null | undefined;
/**

@@ -48,5 +65,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getLeft(): BinaryTreeNode<T> | null | undefined;
set left(v: BinaryTreeNode<T> | null | undefined);
protected _right?: BinaryTreeNode<T> | null;
get right(): BinaryTreeNode<T> | null | undefined;
/**

@@ -56,5 +70,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getRight(): BinaryTreeNode<T> | null | undefined;
set right(v: BinaryTreeNode<T> | null | undefined);
protected _parent: BinaryTreeNode<T> | null | undefined;
get parent(): BinaryTreeNode<T> | null | undefined;
/**

@@ -64,5 +75,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getParent(): BinaryTreeNode<T> | null | undefined;
set parent(v: BinaryTreeNode<T> | null | undefined);
protected _familyPosition: FamilyPosition;
get familyPosition(): FamilyPosition;
/**

@@ -72,5 +80,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getFamilyPosition(): FamilyPosition;
set familyPosition(v: FamilyPosition);
protected _count: number;
get count(): number;
/**

@@ -80,5 +85,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getCount(): number;
set count(v: number);
protected _height: number;
get height(): number;
/**

@@ -88,4 +90,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getHeight(): number;
set height(v: number);
constructor(id: BinaryTreeNodeId, val: T, count?: number);
swapLocation(swapNode: BinaryTreeNode<T>): BinaryTreeNode<T>;

@@ -116,2 +116,9 @@ clone(): BinaryTreeNode<T>;

get root(): BinaryTreeNode<T> | null;
protected set root(v: BinaryTreeNode<T> | null);
protected _size: number;
get size(): number;
protected set size(v: number);
protected _count: number;
get count(): number;
protected set count(v: number);
/**

@@ -122,5 +129,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.

getRoot(): BinaryTreeNode<T> | null;
protected set root(v: BinaryTreeNode<T> | null);
protected _size: number;
get size(): number;
/**

@@ -130,5 +134,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getSize(): number;
protected set size(v: number);
protected _count: number;
get count(): number;
/**

@@ -138,3 +139,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getCount(): number;
protected set count(v: number);
/**

@@ -141,0 +141,0 @@ * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is

@@ -13,2 +13,18 @@ /**

get start(): number;
set start(v: number);
protected _end: number;
get end(): number;
set end(v: number);
protected _val: SegmentTreeNodeVal | null;
get val(): SegmentTreeNodeVal | null;
set val(v: SegmentTreeNodeVal | null);
protected _sum: number;
get sum(): number;
set sum(v: number);
protected _left: SegmentTreeNode | null;
get left(): SegmentTreeNode | null;
set left(v: SegmentTreeNode | null);
protected _right: SegmentTreeNode | null;
get right(): SegmentTreeNode | null;
set right(v: SegmentTreeNode | null);
/**

@@ -18,5 +34,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getStart(): number;
set start(v: number);
protected _end: number;
get end(): number;
/**

@@ -26,5 +39,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getEnd(): number;
set end(v: number);
protected _val: SegmentTreeNodeVal | null;
get val(): SegmentTreeNodeVal | null;
/**

@@ -34,5 +44,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getVal(): SegmentTreeNodeVal | null;
set val(v: SegmentTreeNodeVal | null);
protected _sum: number;
get sum(): number;
/**

@@ -42,5 +49,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getSum(): number;
set sum(v: number);
protected _left: SegmentTreeNode | null;
get left(): SegmentTreeNode | null;
/**

@@ -50,5 +54,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getLeft(): SegmentTreeNode | null;
set left(v: SegmentTreeNode | null);
protected _right: SegmentTreeNode | null;
get right(): SegmentTreeNode | null;
/**

@@ -58,3 +59,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getRight(): SegmentTreeNode | null;
set right(v: SegmentTreeNode | null);
}

@@ -77,2 +77,3 @@ export declare class SegmentTree {

get root(): SegmentTreeNode | null;
set root(v: SegmentTreeNode | null);
/**

@@ -82,3 +83,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getRoot(): SegmentTreeNode | null;
set root(v: SegmentTreeNode | null);
/**

@@ -85,0 +85,0 @@ * The function builds a segment tree by recursively dividing the given range into smaller segments and creating nodes

@@ -34,8 +34,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getStart = function () {
return this._start;
};
Object.defineProperty(SegmentTreeNode.prototype, "end", {

@@ -51,8 +45,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getEnd = function () {
return this._end;
};
Object.defineProperty(SegmentTreeNode.prototype, "val", {

@@ -68,8 +56,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getVal = function () {
return this._val;
};
Object.defineProperty(SegmentTreeNode.prototype, "sum", {

@@ -85,8 +67,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getSum = function () {
return this._sum;
};
Object.defineProperty(SegmentTreeNode.prototype, "left", {

@@ -102,8 +78,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getLeft = function () {
return this._left;
};
Object.defineProperty(SegmentTreeNode.prototype, "right", {

@@ -122,2 +92,32 @@ get: function () {

*/
SegmentTreeNode.prototype.getStart = function () {
return this._start;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getEnd = function () {
return this._end;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getVal = function () {
return this._val;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getSum = function () {
return this._sum;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getLeft = function () {
return this._left;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
SegmentTreeNode.prototype.getRight = function () {

@@ -124,0 +124,0 @@ return this._right;

import type { DijkstraResult, IGraph, VertexId } from '../types';
export declare class AbstractVertex {
constructor(id: VertexId);
protected _id: VertexId;
get id(): VertexId;
set id(v: VertexId);
/**

@@ -9,4 +11,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getId(): VertexId;
set id(v: VertexId);
constructor(id: VertexId);
}

@@ -23,2 +23,6 @@ export declare abstract class AbstractEdge {

get weight(): number;
set weight(v: number);
private _hashCode;
get hashCode(): string;
set hashCode(v: string);
/**

@@ -28,5 +32,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getWeight(): number;
set weight(v: number);
private _hashCode;
get hashCode(): string;
/**

@@ -36,3 +37,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getHashCode(): string;
set hashCode(v: string);
}

@@ -39,0 +39,0 @@ export declare abstract class AbstractGraph<V extends AbstractVertex, E extends AbstractEdge> implements IGraph<V, E> {

@@ -94,8 +94,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
AbstractEdge.prototype.getWeight = function () {
return this._weight;
};
Object.defineProperty(AbstractEdge.prototype, "hashCode", {

@@ -114,2 +108,8 @@ get: function () {

*/
AbstractEdge.prototype.getWeight = function () {
return this._weight;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
AbstractEdge.prototype.getHashCode = function () {

@@ -116,0 +116,0 @@ return this._hashCode;

@@ -24,2 +24,6 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

get src(): VertexId;
set src(v: VertexId);
private _dest;
get dest(): VertexId;
set dest(v: VertexId);
/**

@@ -29,5 +33,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getSrc(): VertexId;
set src(v: VertexId);
private _dest;
get dest(): VertexId;
/**

@@ -37,3 +38,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getDest(): VertexId;
set dest(v: VertexId);
}

@@ -40,0 +40,0 @@ export declare class DirectedGraph<V extends DirectedVertex, E extends DirectedEdge> extends AbstractGraph<V, E> implements IDirectedGraph<V, E> {

@@ -104,8 +104,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DirectedEdge.prototype.getSrc = function () {
return this._src;
};
Object.defineProperty(DirectedEdge.prototype, "dest", {

@@ -124,2 +118,8 @@ get: function () {

*/
DirectedEdge.prototype.getSrc = function () {
return this._src;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DirectedEdge.prototype.getDest = function () {

@@ -126,0 +126,0 @@ return this._dest;

@@ -23,2 +23,3 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

get vertices(): [VertexId, VertexId];
set vertices(v: [VertexId, VertexId]);
/**

@@ -28,7 +29,8 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getVertices(): [VertexId, VertexId];
set vertices(v: [VertexId, VertexId]);
}
export declare class UndirectedGraph<V extends UndirectedVertex, E extends UndirectedEdge> extends AbstractGraph<V, E> {
constructor();
protected _edges: Map<V, E[]>;
get edges(): Map<V, E[]>;
protected set edges(v: Map<V, E[]>);
/**

@@ -38,4 +40,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getEdges(): Map<V, E[]>;
protected set edges(v: Map<V, E[]>);
constructor();
/**

@@ -42,0 +42,0 @@ * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.

@@ -9,4 +9,6 @@ /**

export declare class CoordinateMap<V> extends Map<any, V> {
constructor(joint?: string);
protected _joint: string;
get joint(): string;
protected set joint(v: string);
/**

@@ -16,4 +18,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getJoint(): string;
protected set joint(v: string);
constructor(joint?: string);
/**

@@ -20,0 +20,0 @@ * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the

@@ -9,4 +9,6 @@ /**

export declare class CoordinateSet extends Set {
constructor(joint?: string);
protected _joint: string;
get joint(): string;
protected set joint(v: string);
/**

@@ -16,4 +18,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getJoint(): string;
protected set joint(v: string);
constructor(joint?: string);
/**

@@ -20,0 +20,0 @@ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after

@@ -11,23 +11,15 @@ /**

export declare abstract class Heap<T> {
/**
* The function is a constructor for a class that initializes a priority callback function based on the
* options provided.
* @param [options] - An optional object that contains configuration options for the Heap.
*/
protected constructor(options?: HeapOptions<T>);
protected abstract _pq: PriorityQueue<HeapItem<T>>;
get pq(): PriorityQueue<HeapItem<T>>;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPq(): PriorityQueue<HeapItem<T>>;
protected set pq(v: PriorityQueue<HeapItem<T>>);
protected _priorityCb: (element: T) => number;
get priorityCb(): (element: T) => number;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPriorityCb(): (element: T) => number;
protected set priorityCb(v: (element: T) => number);
/**
* The function is a constructor for a class that initializes a priority callback function based on the
* options provided.
* @param [options] - An optional object that contains configuration options for the Heap.
*/
protected constructor(options?: HeapOptions<T>);
/**
* The function returns the size of a priority queue.

@@ -40,2 +32,10 @@ * @returns The size of the priority queue.

*/
getPq(): PriorityQueue<HeapItem<T>>;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPriorityCb(): (element: T) => number;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number;

@@ -42,0 +42,0 @@ /**

@@ -32,8 +32,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
Heap.prototype.getPq = function () {
return this._pq;
};
Object.defineProperty(Heap.prototype, "priorityCb", {

@@ -49,8 +43,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
Heap.prototype.getPriorityCb = function () {
return this._priorityCb;
};
Object.defineProperty(Heap.prototype, "size", {

@@ -70,2 +58,14 @@ /**

*/
Heap.prototype.getPq = function () {
return this._pq;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
Heap.prototype.getPriorityCb = function () {
return this._priorityCb;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
Heap.prototype.getSize = function () {

@@ -72,0 +72,0 @@ return this._pq.size;

export declare class DoublyLinkedListNode<T> {
constructor(nodeValue: T);
protected _val: T;

@@ -11,7 +12,14 @@ get val(): T;

set prev(v: DoublyLinkedListNode<T> | null);
constructor(nodeValue: T);
}
export declare class DoublyLinkedList<T> {
constructor();
protected _first: DoublyLinkedListNode<T> | null;
get first(): DoublyLinkedListNode<T> | null;
protected set first(v: DoublyLinkedListNode<T> | null);
protected _last: DoublyLinkedListNode<T> | null;
get last(): DoublyLinkedListNode<T> | null;
protected set last(v: DoublyLinkedListNode<T> | null);
protected _size: number;
get size(): number;
protected set size(v: number);
/**

@@ -21,5 +29,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getFirst(): DoublyLinkedListNode<T> | null;
protected set first(v: DoublyLinkedListNode<T> | null);
protected _last: DoublyLinkedListNode<T> | null;
get last(): DoublyLinkedListNode<T> | null;
/**

@@ -29,5 +34,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getLast(): DoublyLinkedListNode<T> | null;
protected set last(v: DoublyLinkedListNode<T> | null);
protected _size: number;
get size(): number;
/**

@@ -37,4 +39,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

getSize(): number;
protected set size(v: number);
constructor();
/**

@@ -41,0 +41,0 @@ * The function adds a new node with a given value to the beginning of a doubly linked list.

@@ -59,8 +59,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DoublyLinkedList.prototype.getFirst = function () {
return this._first;
};
Object.defineProperty(DoublyLinkedList.prototype, "last", {

@@ -76,8 +70,2 @@ get: function () {

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DoublyLinkedList.prototype.getLast = function () {
return this._last;
};
Object.defineProperty(DoublyLinkedList.prototype, "size", {

@@ -96,2 +84,14 @@ get: function () {

*/
DoublyLinkedList.prototype.getFirst = function () {
return this._first;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DoublyLinkedList.prototype.getLast = function () {
return this._last;
};
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
DoublyLinkedList.prototype.getSize = function () {

@@ -98,0 +98,0 @@ return this._size;

@@ -9,2 +9,3 @@ /**

export declare class SinglyLinkedListNode<NodeVal = any> {
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
protected _val: NodeVal;

@@ -22,3 +23,2 @@ get val(): NodeVal;

set list(value: SinglyLinkedList<NodeVal> | null);
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
get index(): number | undefined;

@@ -45,2 +45,8 @@ /**

export declare class SinglyLinkedList<NodeVal = any> {
/**
* The constructor initializes a linked list with the given arguments as nodes.
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
* arguments of type NodeVal.
*/
constructor(...args: NodeVal[]);
protected _head: SinglyLinkedListNode<NodeVal> | null;

@@ -56,8 +62,2 @@ get head(): SinglyLinkedListNode<NodeVal> | null;

/**
* The constructor initializes a linked list with the given arguments as nodes.
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
* arguments of type NodeVal.
*/
constructor(...args: NodeVal[]);
/**
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.

@@ -64,0 +64,0 @@ * @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It

@@ -10,10 +10,3 @@ /**

export declare class PriorityQueue<T = number> {
protected _nodes: T[];
get nodes(): T[];
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getNodes(): T[];
protected set nodes(value: T[]);
/**
* The constructor initializes a priority queue with the given options, including an array of nodes and a comparator

@@ -24,2 +17,5 @@ * function.

constructor(options: PriorityQueueOptions<T>);
protected _nodes: T[];
get nodes(): T[];
protected set nodes(value: T[]);
get size(): number;

@@ -43,2 +39,6 @@ /**

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getNodes(): T[];
/**
* The "add" function adds a node to the heap and ensures that the heap property is maintained.

@@ -45,0 +45,0 @@ * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node

@@ -70,8 +70,2 @@ "use strict";

});
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
PriorityQueue.prototype.getNodes = function () {
return this._nodes;
};
Object.defineProperty(PriorityQueue.prototype, "size", {

@@ -107,2 +101,8 @@ get: function () {

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
PriorityQueue.prototype.getNodes = function () {
return this._nodes;
};
/**
* The "add" function adds a node to the heap and ensures that the heap property is maintained.

@@ -109,0 +109,0 @@ * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node

@@ -12,2 +12,3 @@ /**

export declare class ObjectDeque<T> {
constructor(capacity?: number);
private _nodes;

@@ -32,3 +33,2 @@ get nodes(): {

protected set size(value: number);
constructor(capacity?: number);
addFirst(value: T): void;

@@ -35,0 +35,0 @@ addLast(value: T): void;

@@ -1,4 +0,1 @@

/**
* A function that emits a side effect and does not return anything.
*/
export type ToThunkFn = () => ReturnType<TrlFn>;

@@ -5,0 +2,0 @@ export type Thunk = () => ReturnType<ToThunkFn> & {

"use strict";
// export type JSONSerializable = {
// [key: string]: any
// }
Object.defineProperty(exports, "__esModule", { value: true });
// export type CaseType =
// 'camel'
// | 'snake'
// | 'pascal'
// | 'constant'
// | 'kebab'
// | 'lower'
// | 'title'
// | 'sentence'
// | 'path'
// | 'dot';
"use strict";
// import _ from 'lodash';
// import type {AnyFunction, CaseType, JSONObject, JSONSerializable} from './types';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -74,197 +72,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.uuidV4 = uuidV4;
// export const isObject = (object: string | JSONObject | boolean | AnyFunction | number) => object != null && typeof object === 'object';
// export const deepObjectStrictEqual = (object1: JSONSerializable, object2: JSONSerializable) => {
// const keys1 = Object.keys(object1);
// const keys2 = Object.keys(object2);
// if (keys1.length !== keys2.length) {
// return false;
// }
// for (const key of keys1) {
// const val1 = object1[key];
// const val2 = object2[key];
// const areObjects = isObject(val1) && isObject(val2);
// if (
// areObjects && !deepObjectStrictEqual(val1, val2) ||
// !areObjects && val1 !== val2
// ) {
// return false;
// }
// }
// return true;
// };
// export class StringUtil {
// // camelCase
// static toCamelCase(str: string) {
// return _.camelCase(str);
// }
//
// // snake_case
// static toSnakeCase(str: string) {
// return _.snakeCase(str);
// }
//
// // PascalCase
// static toPascalCase(str: string) {
// return _.startCase(_.camelCase(str)).replace(/ /g, '');
// }
//
// // CONSTANT_CASE
// static toConstantCase(str: string) {
// return _.upperCase(str).replace(/ /g, '_');
// }
//
// // kebab-case
// static toKebabCase(str: string) {
// return _.kebabCase(str);
// }
//
// // lowercase
// static toLowerCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '');
// }
//
// // Title Case
// static toTitleCase(str: string) {
// return _.startCase(_.camelCase(str));
// }
//
// // Sentence case
// static toSentenceCase(str: string) {
// return _.upperFirst(_.lowerCase(str));
// }
//
// // path/case
// static toPathCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '/');
// }
//
// // dot.case
// static toDotCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '.');
// }
// }
// export const deepKeysConvert = (obj: any, toType?: CaseType): any => {
// const _toType = toType || 'snake';
// if (Array.isArray(obj)) {
// return obj.map(v => deepKeysConvert(v, _toType));
// } else if (obj !== null && obj.constructor === Object) {
// return Object.keys(obj).reduce(
// (result, key) => {
// let newKey = '';
// switch (_toType) {
// case 'camel':
// newKey = StringUtil.toCamelCase(key);
// break;
// case 'snake':
// newKey = StringUtil.toSnakeCase(key);
// break;
// case 'pascal':
// newKey = StringUtil.toPascalCase(key);
// break;
// case 'constant':
// newKey = StringUtil.toConstantCase(key);
// break;
// case 'kebab':
// newKey = StringUtil.toKebabCase(key);
// break;
// case 'lower':
// newKey = StringUtil.toLowerCase(key);
// break;
// case 'title':
// newKey = StringUtil.toTitleCase(key);
// break;
// case 'sentence':
// newKey = StringUtil.toSentenceCase(key);
// break;
// case 'path':
// newKey = StringUtil.toPathCase(key);
// break;
// case 'dot':
// newKey = StringUtil.toDotCase(key);
// break;
// default:
// newKey = StringUtil.toDotCase(key);
// break;
// }
// return {
// ...result,
// [newKey]: deepKeysConvert(obj[key], _toType),
// };
// },
// {},
// );
// }
// return obj;
// };
// export const deepRemoveByKey = (obj: any, keysToBeRemoved: string[]) => {
// const result = _.transform(obj, function (result: JSONSerializable, value: any, key: string) {
// if (_.isObject(value)) {
// value = deepRemoveByKey(value, keysToBeRemoved);
// }
// if (!keysToBeRemoved.includes(key)) {
// _.isArray(obj) ? result.push(value) : result[key] = value;
// }
// });
// return result as typeof obj;
// };
// export const deepRenameKeys = (obj: JSONSerializable, keysMap: { [key in string]: string }) => {
// return _.transform(obj, function (result: JSONSerializable, value: any, key: string | number) {
// const currentKey = keysMap[key] || key;
// result[currentKey] = _.isObject(value) ? deepRenameKeys(value, keysMap) : value;
// });
// };
// export const deepReplaceValues = (obj: JSONSerializable, keyReducerMap: { [key in string]: (item: JSONSerializable) => any }) => {
// const newObject = _.clone(obj) as JSONSerializable;
// _.each(obj, (val: any, key: string) => {
// for (const item in keyReducerMap) {
// if (key === item) {
// newObject[key] = keyReducerMap[item](newObject);
// } else if (typeof (val) === 'object' || val instanceof Array) {
// newObject[key] = deepReplaceValues(val, keyReducerMap);
// }
// }
// });
// return newObject;
// };
// TODO determine depth and pass root node as a param through callback
// export const deepAdd = (obj: JSONSerializable, keyReducerMap: { [key in string]: (item: JSONSerializable) => any }, isItemRootParent?: boolean) => {
// const newObject = _.clone(obj) as JSONObject | [];
// if (_.isObject(newObject) && !_.isArray(newObject)) {
// for (const item in keyReducerMap) {
// newObject[item] = keyReducerMap[item](newObject);
// }
// }
// _.each(obj, (val: any, key: string | number) => {
// if (_.isObject(val)) {
// for (const item in keyReducerMap) {
// // @ts-ignore
// newObject[key] = deepAdd(val, keyReducerMap, isItemRootParent);
// }
// }
// });
// return newObject;
// };
// const styleString = (color: string) => `color: ${color}; font-weight: bold`;
// const styleHeader = (header: string) => `%c[${header}]`;
// export const bunnyConsole = {
// log: (headerLog = 'bunny', ...args: any[]) => {
// return console.log(styleHeader(headerLog), styleString('black'), ...args);
// },
// warn: (headerLog = 'bunny', ...args: any[]) => {
// return console.warn(styleHeader(headerLog), styleString('orange'), ...args);
// },
// error: (headerLog = 'bunny', ...args: any[]) => {
// return console.error(styleHeader(headerLog), styleString('red'), ...args);
// }
// };
// export const timeStart = () => {
// return performance ? performance.now() : new Date().getTime();
// };
// export const timeEnd = (startTime: number, headerLog?: string, consoleConditionFn?: (timeSpent: number) => boolean) => {
// const timeSpent = (performance ? performance.now() : new Date().getTime()) - startTime;
// const isPassCondition = consoleConditionFn ? consoleConditionFn(timeSpent) : true;
// if (isPassCondition) {
// bunnyConsole.log(headerLog ? headerLog : 'time spent', timeSpent.toFixed(2));
// }
// };
var arrayRemove = function (array, predicate) {

@@ -271,0 +74,0 @@ var i = -1, len = array ? array.length : 0;

{
"name": "data-structure-typed",
"version": "1.15.1",
"version": "1.15.2",
"description": "Explore our comprehensive Javascript Data Structure / TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",

@@ -11,3 +11,3 @@ "main": "dist/index.js",

"deps:check": "dependency-cruiser src",
"build:publish": "npm run test && npm run build && npm run build:docs && npm run publish"
"build:publish": "npm run test && npm run build && npm run build:docs && npm publish"
},

@@ -53,3 +53,2 @@ "repository": {

"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.197",
"@types/node": "^20.4.9",

@@ -63,4 +62,3 @@ "dependency-cruiser": "^13.1.2",

"dependencies": {
"lodash": "^4.17.21"
}
}

@@ -0,4 +1,18 @@

# What
Javascript Data Structure, TypeScript Data Structure Library
## Brief
Javascript & TypeScript Data Structure Library.
Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a
wide range of data structures
## Data Structures
Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed
Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack,
Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
# How
## install

@@ -18,2 +32,103 @@

### Binary Search Tree (BST) snippet
```typescript
import {BST, BSTNode} from 'data-structure-typed';
const tree = new BST();
expect(tree).toBeInstanceOf(BST);
const ids = [11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
tree.addMany(ids);
expect(tree.root).toBeInstanceOf(BSTNode);
if (tree.root) expect(tree.root.id).toBe(11);
expect(tree.count).toBe(16);
expect(tree.has(6)).toBe(true);
const node6 = tree.get(6);
expect(node6 && tree.getHeight(node6)).toBe(2);
expect(node6 && tree.getDepth(node6)).toBe(3);
const nodeId10 = tree.get(10, 'id');
expect(nodeId10?.id).toBe(10);
const nodeVal9 = tree.get(9, 'val');
expect(nodeVal9?.id).toBe(9);
const nodesByCount1 = tree.getNodes(1, 'count');
expect(nodesByCount1.length).toBe(16);
const leftMost = tree.getLeftMost();
expect(leftMost?.id).toBe(1);
const node15 = tree.get(15);
const minNodeBySpecificNode = node15 && tree.getLeftMost(node15);
expect(minNodeBySpecificNode?.id).toBe(12);
const subTreeSum = node15 && tree.subTreeSum(node15);
expect(subTreeSum).toBe(70);
const lesserSum = tree.lesserSum(10);
expect(lesserSum).toBe(45);
expect(node15).toBeInstanceOf(BSTNode);
if (node15 instanceof BSTNode) {
const subTreeAdd = tree.subTreeAdd(node15, 1, 'count');
expect(subTreeAdd).toBeDefined();
}
const node11 = tree.get(11);
expect(node11).toBeInstanceOf(BSTNode);
if (node11 instanceof BSTNode) {
const allGreaterNodesAdded = tree.allGreaterNodesAdd(node11, 2, 'count');
expect(allGreaterNodesAdded).toBeDefined();
}
const dfsInorderNodes = tree.DFS('in', 'node');
expect(dfsInorderNodes[0].id).toBe(1);
expect(dfsInorderNodes[dfsInorderNodes.length - 1].id).toBe(16);
tree.balance();
expect(tree.isBalanced()).toBe(true);
const bfsNodesAfterBalanced = tree.BFS('node');
expect(bfsNodesAfterBalanced[0].id).toBe(8);
expect(bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].id).toBe(16);
const removed11 = tree.remove(11, true);
expect(removed11).toBeInstanceOf(Array);
expect(removed11[0]).toBeDefined();
expect(removed11[0].deleted).toBeDefined();
if (removed11[0].deleted) expect(removed11[0].deleted.id).toBe(11);
expect(tree.isAVLBalanced()).toBe(true);
expect(node15 && tree.getHeight(node15)).toBe(2);
const removed1 = tree.remove(1, true);
expect(removed1).toBeInstanceOf(Array);
expect(removed1[0]).toBeDefined();
expect(removed1[0].deleted).toBeDefined();
if (removed1[0].deleted) expect(removed1[0].deleted.id).toBe(1);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(4);
// The code for removing these nodes (4, 10, 15, 5, 13, 3, 8, 6, 7, 9, 14) in sequence has been omitted.
expect(tree.isAVLBalanced()).toBe(false);
const bfsIDs = tree.BFS();
expect(bfsIDs[0]).toBe(2);
expect(bfsIDs[1]).toBe(12);
expect(bfsIDs[2]).toBe(16);
const bfsNodes = tree.BFS('node');
expect(bfsNodes[0].id).toBe(2);
expect(bfsNodes[1].id).toBe(12);
expect(bfsNodes[2].id).toBe(16);
```
## Live Examples

@@ -25,10 +140,264 @@

## Data Structures
### Directed Graph simple snippet
Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a
wide range of data structures:
Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed
Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack,
Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
```typescript
import {DirectedGraph, DirectedVertex, DirectedEdge, VertexId} from 'data-structure-typed';
let graph: DirectedGraph<DirectedVertex, DirectedEdge>;
beforeEach(() => {
graph = new DirectedGraph();
});
it('should add vertices', () => {
const vertex1 = new DirectedVertex('A');
const vertex2 = new DirectedVertex('B');
graph.addVertex(vertex1);
graph.addVertex(vertex2);
expect(graph.hasVertex(vertex1)).toBe(true);
expect(graph.hasVertex(vertex2)).toBe(true);
});
it('should add edges', () => {
const vertex1 = new DirectedVertex('A');
const vertex2 = new DirectedVertex('B');
const edge = new DirectedEdge('A', 'B');
graph.addVertex(vertex1);
graph.addVertex(vertex2);
graph.addEdge(edge);
expect(graph.hasEdge('A', 'B')).toBe(true);
expect(graph.hasEdge('B', 'A')).toBe(false);
});
it('should remove edges', () => {
const vertex1 = new DirectedVertex('A');
const vertex2 = new DirectedVertex('B');
const edge = new DirectedEdge('A', 'B');
graph.addVertex(vertex1);
graph.addVertex(vertex2);
graph.addEdge(edge);
expect(graph.removeEdge(edge)).toBe(edge);
expect(graph.hasEdge('A', 'B')).toBe(false);
});
it('should perform topological sort', () => {
const vertexA = new DirectedVertex('A');
const vertexB = new DirectedVertex('B');
const vertexC = new DirectedVertex('C');
const edgeAB = new DirectedEdge('A', 'B');
const edgeBC = new DirectedEdge('B', 'C');
graph.addVertex(vertexA);
graph.addVertex(vertexB);
graph.addVertex(vertexC);
graph.addEdge(edgeAB);
graph.addEdge(edgeBC);
const topologicalOrder = graph.topologicalSort();
if (topologicalOrder) expect(topologicalOrder.map(v => v.id)).toEqual(['A', 'B', 'C']);
});
```
### Directed Graph complex snippet
```typescript
import {DirectedGraph, DirectedVertex, DirectedEdge, VertexId} from 'data-structure-typed';
class MyVertex extends DirectedVertex {
private _data: string;
get data(): string {
return this._data;
}
set data(value: string) {
this._data = value;
}
constructor(id: VertexId, data: string) {
super(id);
this._data = data;
}
}
class MyEdge extends DirectedEdge {
private _data: string;
get data(): string {
return this._data;
}
set data(value: string) {
this._data = value;
}
constructor(v1: VertexId, v2: VertexId, weight: number, data: string) {
super(v1, v2, weight);
this._data = data;
}
}
describe('DirectedGraph Test3', () => {
const myGraph = new DirectedGraph<MyVertex, MyEdge>();
it('should test graph operations', () => {
const vertex1 = new MyVertex(1, 'data1');
const vertex2 = new MyVertex(2, 'data2');
const vertex3 = new MyVertex(3, 'data3');
const vertex4 = new MyVertex(4, 'data4');
const vertex5 = new MyVertex(5, 'data5');
const vertex6 = new MyVertex(6, 'data6');
const vertex7 = new MyVertex(7, 'data7');
const vertex8 = new MyVertex(8, 'data8');
const vertex9 = new MyVertex(9, 'data9');
myGraph.addVertex(vertex1);
myGraph.addVertex(vertex2);
myGraph.addVertex(vertex3);
myGraph.addVertex(vertex4);
myGraph.addVertex(vertex5);
myGraph.addVertex(vertex6);
myGraph.addVertex(vertex7);
myGraph.addVertex(vertex8);
myGraph.addVertex(vertex9);
myGraph.addEdge(new MyEdge(1, 2, 10, 'edge-data1-2'));
myGraph.addEdge(new MyEdge(2, 1, 20, 'edge-data2-1'));
expect(myGraph.getEdge(1, 2)).toBeTruthy();
expect(myGraph.getEdge(2, 1)).toBeTruthy();
expect(myGraph.getEdge(1, '100')).toBeFalsy();
myGraph.removeEdgeBetween(1, 2);
expect(myGraph.getEdge(1, 2)).toBeFalsy();
myGraph.addEdge(new MyEdge(3, 1, 3, 'edge-data-3-1'));
myGraph.addEdge(new MyEdge(1, 9, 19, 'edge-data1-9'));
myGraph.addEdge(new MyEdge(9, 7, 97, 'edge-data9-7'));
myGraph.addEdge(new MyEdge(7, 9, 79, 'edge-data7-9'));
myGraph.addEdge(new MyEdge(1, 4, 14, 'edge-data1-4'));
myGraph.addEdge(new MyEdge(4, 7, 47, 'edge-data4-7'));
myGraph.addEdge(new MyEdge(1, 2, 12, 'edge-data1-2'));
myGraph.addEdge(new MyEdge(2, 3, 23, 'edge-data2-3'));
myGraph.addEdge(new MyEdge(3, 5, 35, 'edge-data3-5'));
myGraph.addEdge(new MyEdge(5, 7, 57, 'edge-data5-7'));
myGraph.addEdge(new MyEdge(7, 3, 73, 'edge-data7-3'));
const topologicalSorted = myGraph.topologicalSort();
expect(topologicalSorted).toBeNull();
const minPath1to7 = myGraph.getMinPathBetween(1, 7);
expect(minPath1to7).toBeInstanceOf(Array);
if (minPath1to7 && minPath1to7.length > 0) {
expect(minPath1to7).toHaveLength(3);
expect(minPath1to7[0]).toBeInstanceOf(MyVertex);
expect(minPath1to7[0].id).toBe(1);
expect(minPath1to7[1].id).toBe(9);
expect(minPath1to7[2].id).toBe(7);
}
const fordResult1 = myGraph.bellmanFord(1);
expect(fordResult1).toBeTruthy();
expect(fordResult1.hasNegativeCycle).toBeUndefined();
const {distMap, preMap, paths, min, minPath} = fordResult1;
expect(distMap).toBeInstanceOf(Map);
expect(distMap.size).toBe(9);
expect(distMap.get(vertex1)).toBe(0);
expect(distMap.get(vertex2)).toBe(12);
expect(distMap.get(vertex3)).toBe(35);
expect(distMap.get(vertex4)).toBe(14);
expect(distMap.get(vertex5)).toBe(70);
expect(distMap.get(vertex6)).toBe(Infinity);
expect(distMap.get(vertex7)).toBe(61);
expect(distMap.get(vertex8)).toBe(Infinity);
expect(distMap.get(vertex9)).toBe(19);
expect(preMap).toBeInstanceOf(Map);
expect(preMap.size).toBe(0);
expect(paths).toBeInstanceOf(Array);
expect(paths.length).toBe(0);
expect(min).toBe(Infinity);
expect(minPath).toBeInstanceOf(Array);
const floydResult = myGraph.floyd();
expect(floydResult).toBeTruthy();
if (floydResult) {
const {costs, predecessor} = floydResult;
expect(costs).toBeInstanceOf(Array);
expect(costs.length).toBe(9);
expect(costs[0]).toEqual([32, 12, 35, 14, 70, Infinity, 61, Infinity, 19]);
expect(costs[1]).toEqual([20, 32, 23, 34, 58, Infinity, 81, Infinity, 39]);
expect(costs[2]).toEqual([3, 15, 38, 17, 35, Infinity, 64, Infinity, 22]);
expect(costs[3]).toEqual([123, 135, 120, 137, 155, Infinity, 47, Infinity, 126]);
expect(costs[4]).toEqual([133, 145, 130, 147, 165, Infinity, 57, Infinity, 136]);
expect(costs[5]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
expect(costs[6]).toEqual([76, 88, 73, 90, 108, Infinity, 137, Infinity, 79]);
expect(costs[7]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
expect(costs[8]).toEqual([173, 185, 170, 187, 205, Infinity, 97, Infinity, 176]);
expect(predecessor).toBeInstanceOf(Array);
expect(predecessor.length).toBe(9);
expect(predecessor[0]).toEqual([vertex2, null, vertex2, null, vertex3, null, vertex4, null, null]);
expect(predecessor[1]).toEqual([null, vertex1, null, vertex1, vertex3, null, vertex4, null, vertex1]);
expect(predecessor[5]).toEqual([null, null, null, null, null, null, null, null, null]);
expect(predecessor[7]).toEqual([null, null, null, null, null, null, null, null, null]);
expect(predecessor[8]).toEqual([vertex7, vertex7, vertex7, vertex7, vertex7, null, null, null, vertex7]);
}
const dijkstraRes12tt = myGraph.dijkstra(1, 2, true, true);
expect(dijkstraRes12tt).toBeTruthy();
if (dijkstraRes12tt) {
const {distMap, minDist, minPath, paths, preMap, seen} = dijkstraRes12tt;
expect(distMap).toBeInstanceOf(Map);
expect(distMap.size).toBe(9);
expect(distMap.get(vertex1)).toBe(0);
expect(distMap.get(vertex2)).toBe(12);
expect(distMap.get(vertex3)).toBe(Infinity);
expect(distMap.get(vertex4)).toBe(14);
expect(distMap.get(vertex5)).toBe(Infinity);
expect(distMap.get(vertex6)).toBe(Infinity);
expect(distMap.get(vertex7)).toBe(Infinity);
expect(distMap.get(vertex8)).toBe(Infinity);
expect(distMap.get(vertex9)).toBe(19);
expect(minDist).toBe(12);
expect(minPath).toBeInstanceOf(Array);
expect(minPath.length).toBe(2);
expect(minPath[0]).toBe(vertex1);
expect(minPath[1]).toBe(vertex2);
expect(paths).toBeInstanceOf(Array);
expect(paths.length).toBe(9);
expect(paths[0]).toBeInstanceOf(Array);
expect(paths[0][0]).toBe(vertex1);
expect(paths[1]).toBeInstanceOf(Array);
expect(paths[1][0]).toBe(vertex1);
expect(paths[1][1]).toBe(vertex2);
expect(paths[2]).toBeInstanceOf(Array);
expect(paths[2][0]).toBe(vertex3);
expect(paths[3]).toBeInstanceOf(Array);
expect(paths[3][0]).toBe(vertex1);
expect(paths[3][1]).toBe(vertex4);
expect(paths[4]).toBeInstanceOf(Array);
expect(paths[4][0]).toBe(vertex5);
expect(paths[5]).toBeInstanceOf(Array);
expect(paths[5][0]).toBe(vertex6);
expect(paths[6]).toBeInstanceOf(Array);
expect(paths[6][0]).toBe(vertex7);
expect(paths[7]).toBeInstanceOf(Array);
expect(paths[7][0]).toBe(vertex8);
expect(paths[8]).toBeInstanceOf(Array);
expect(paths[8][0]).toBe(vertex1);
expect(paths[8][1]).toBe(vertex9);
}
});
});
```
## API docs

@@ -104,2 +473,3 @@

# Why

@@ -369,2 +739,3 @@ ## Complexities

![overview diagram](src/assets/overview-diagram-of-data-structures.png)

@@ -371,0 +742,0 @@ ![complexities](src/assets/complexities-diff.jpg)

@@ -33,3 +33,10 @@ /**

constructor(id: BinaryTreeNodeId, val: T, count?: number) {
this._id = id;
this._val = val;
this._count = count ?? 1;
}
protected _id: BinaryTreeNodeId;
get id(): BinaryTreeNodeId {

@@ -39,9 +46,2 @@ return this._id;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getId(): BinaryTreeNodeId {
return this._id;
}
set id(v: BinaryTreeNodeId) {

@@ -56,9 +56,2 @@ this._id = v;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getVal(): T {
return this._val;
}
set val(v: T) {

@@ -69,2 +62,3 @@ this._val = v;

protected _left?: BinaryTreeNode<T> | null;
get left(): BinaryTreeNode<T> | null | undefined {

@@ -74,9 +68,2 @@ return this._left;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLeft(): BinaryTreeNode<T> | null | undefined {
return this._left;
}
set left(v: BinaryTreeNode<T> | null | undefined) {

@@ -91,2 +78,3 @@ if (v) {

protected _right?: BinaryTreeNode<T> | null;
get right(): BinaryTreeNode<T> | null | undefined {

@@ -96,9 +84,2 @@ return this._right;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getRight(): BinaryTreeNode<T> | null | undefined {
return this._right;
}
set right(v: BinaryTreeNode<T> | null | undefined) {

@@ -113,2 +94,3 @@ if (v) {

protected _parent: BinaryTreeNode<T> | null | undefined;
get parent(): BinaryTreeNode<T> | null | undefined {

@@ -118,9 +100,2 @@ return this._parent;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getParent(): BinaryTreeNode<T> | null | undefined {
return this._parent;
}
set parent(v: BinaryTreeNode<T> | null | undefined) {

@@ -131,2 +106,3 @@ this._parent = v;

protected _familyPosition: FamilyPosition = FamilyPosition.root;
get familyPosition(): FamilyPosition {

@@ -136,9 +112,2 @@ return this._familyPosition;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getFamilyPosition(): FamilyPosition {
return this._familyPosition;
}
set familyPosition(v: FamilyPosition) {

@@ -149,2 +118,3 @@ this._familyPosition = v;

protected _count = 1;
get count(): number {

@@ -154,9 +124,2 @@ return this._count;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getCount(): number {
return this._count;
}
set count(v: number) {

@@ -167,2 +130,3 @@ this._count = v;

protected _height = 0;
get height(): number {

@@ -172,19 +136,62 @@ return this._height;

set height(v: number) {
this._height = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getHeight(): number {
return this._height;
getId(): BinaryTreeNodeId {
return this._id;
}
set height(v: number) {
this._height = v;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getVal(): T {
return this._val;
}
constructor(id: BinaryTreeNodeId, val: T, count?: number) {
this._id = id;
this._val = val;
this._count = count ?? 1;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLeft(): BinaryTreeNode<T> | null | undefined {
return this._left;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getRight(): BinaryTreeNode<T> | null | undefined {
return this._right;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getParent(): BinaryTreeNode<T> | null | undefined {
return this._parent;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getFamilyPosition(): FamilyPosition {
return this._familyPosition;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getCount(): number {
return this._count;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getHeight(): number {
return this._height;
}
swapLocation(swapNode: BinaryTreeNode<T>): BinaryTreeNode<T> {

@@ -253,10 +260,2 @@ const {val, count, height} = swapNode;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
* @returns The method is returning either a BinaryTreeNode object of type T or null.
*/
getRoot(): BinaryTreeNode<T> | null {
return this._root;
}
protected set root(v: BinaryTreeNode<T> | null) {

@@ -276,9 +275,2 @@ if (v) {

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number {
return this._size;
}
protected set size(v: number) {

@@ -294,5 +286,24 @@ this._size = v;

protected set count(v: number) {
this._count = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Getters (using the same name as the property) while utilizing separate method names for Setters.
* @returns The method is returning either a BinaryTreeNode object of type T or null.
*/
getRoot(): BinaryTreeNode<T> | null {
return this._root;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number {
return this._size;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getCount(): number {

@@ -302,6 +313,2 @@ return this._count;

protected set count(v: number) {
this._count = v;
}
/**

@@ -308,0 +315,0 @@ * The function creates a new binary tree node with the given id, value, and count, or returns null if the value is

@@ -23,8 +23,3 @@ /**

}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getStart(): number {
return this._start;
}
set start(v: number) {

@@ -35,11 +30,7 @@ this._start = v;

protected _end = 0;
get end(): number {
return this._end;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getEnd(): number {
return this._end;
}
set end(v: number) {

@@ -50,11 +41,7 @@ this._end = v;

protected _val: SegmentTreeNodeVal | null = null;
get val(): SegmentTreeNodeVal | null {
return this._val;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getVal(): SegmentTreeNodeVal | null {
return this._val;
}
set val(v: SegmentTreeNodeVal | null) {

@@ -65,11 +52,7 @@ this._val = v;

protected _sum = 0;
get sum(): number {
return this._sum;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSum(): number {
return this._sum;
}
set sum(v: number) {

@@ -80,11 +63,7 @@ this._sum = v;

protected _left: SegmentTreeNode | null = null;
get left(): SegmentTreeNode | null {
return this._left;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLeft(): SegmentTreeNode | null {
return this._left;
}
set left(v: SegmentTreeNode | null) {

@@ -95,14 +74,52 @@ this._left = v;

protected _right: SegmentTreeNode | null = null;
get right(): SegmentTreeNode | null {
return this._right;
}
set right(v: SegmentTreeNode | null) {
this._right = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getStart(): number {
return this._start;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getEnd(): number {
return this._end;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getVal(): SegmentTreeNodeVal | null {
return this._val;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSum(): number {
return this._sum;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLeft(): SegmentTreeNode | null {
return this._left;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getRight(): SegmentTreeNode | null {
return this._right;
}
set right(v: SegmentTreeNode | null) {
this._right = v;
}
}

@@ -137,2 +154,7 @@

}
set root(v: SegmentTreeNode | null) {
this._root = v;
}
/**

@@ -144,5 +166,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
set root(v: SegmentTreeNode | null) {
this._root = v;
}

@@ -149,0 +168,0 @@ /**

@@ -13,3 +13,8 @@ /**

export class AbstractVertex {
constructor(id: VertexId) {
this._id = id;
}
protected _id: VertexId;
get id(): VertexId {

@@ -19,2 +24,6 @@ return this._id;

set id(v: VertexId) {
this._id = v;
}
/**

@@ -26,10 +35,2 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
set id(v: VertexId) {
this._id = v;
}
constructor(id: VertexId) {
this._id = id;
}
}

@@ -57,9 +58,2 @@

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getWeight(): number {
return this._weight;
}
set weight(v: number) {

@@ -70,2 +64,3 @@ this._weight = v;

private _hashCode: string;
get hashCode(): string {

@@ -75,12 +70,19 @@ return this._hashCode;

set hashCode(v: string) {
this._hashCode = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getWeight(): number {
return this._weight;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getHashCode(): string {
return this._hashCode;
}
set hashCode(v: string) {
this._hashCode = v;
}
}

@@ -87,0 +89,0 @@

@@ -43,8 +43,3 @@ /**

}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSrc(): VertexId {
return this._src;
}
set src(v: VertexId) {

@@ -55,14 +50,24 @@ this._src = v;

private _dest: VertexId;
get dest(): VertexId {
return this._dest;
}
set dest(v: VertexId) {
this._dest = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSrc(): VertexId {
return this._src;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getDest(): VertexId {
return this._dest;
}
set dest(v: VertexId) {
this._dest = v;
}
}

@@ -164,10 +169,10 @@

if (srcOutEdges) {
/**
* The removeEdge function removes an edge from a graph and returns the removed edge, or null if the edge was not
* found.
* @param {E} edge - The `edge` parameter represents the edge that you want to remove from the graph. It should be an
* object that has `src` and `dest` properties, which represent the source and destination vertices of the edge,
* respectively.
* @returns The method `removeEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
*/
/**
* The removeEdge function removes an edge from a graph and returns the removed edge, or null if the edge was not
* found.
* @param {E} edge - The `edge` parameter represents the edge that you want to remove from the graph. It should be an
* object that has `src` and `dest` properties, which represent the source and destination vertices of the edge,
* respectively.
* @returns The method `removeEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
*/
arrayRemove<E>(srcOutEdges, (edge: DirectedEdge) => edge.dest === dest.id);

@@ -190,3 +195,3 @@ }

*/
removeEdge(edge: E ): E | null {
removeEdge(edge: E): E | null {
let removed: E | null = null;

@@ -193,0 +198,0 @@ const src = this.getVertex(edge.src);

@@ -41,2 +41,7 @@ /**

}
set vertices(v: [VertexId, VertexId]) {
this._vertices = v;
}
/**

@@ -48,12 +53,20 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
set vertices(v: [VertexId, VertexId]) {
this._vertices = v;
}
}
export class UndirectedGraph<V extends UndirectedVertex, E extends UndirectedEdge> extends AbstractGraph<V, E> {
constructor() {
super();
this._edges = new Map<V, E[]>();
}
protected _edges: Map<V, E[]>;
get edges(): Map<V, E[]> {
return this._edges;
}
protected set edges(v: Map<V, E[]>) {
this._edges = v;
}
/**

@@ -65,11 +78,3 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
protected set edges(v: Map<V, E[]>) {
this._edges = v;
}
constructor() {
super();
this._edges = new Map<V, E[]>();
}
/**

@@ -76,0 +81,0 @@ * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.

@@ -9,6 +9,17 @@ /**

export class CoordinateMap<V> extends Map<any, V> {
constructor(joint?: string) {
super();
if (joint !== undefined) this._joint = joint;
}
protected _joint: string = '_';
get joint(): string {
return this._joint;
}
protected set joint(v: string) {
this._joint = v;
}
/**

@@ -20,11 +31,3 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
protected set joint(v: string) {
this._joint = v;
}
constructor(joint?: string) {
super();
if (joint !== undefined) this._joint = joint;
}
/**

@@ -31,0 +34,0 @@ * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the

@@ -9,6 +9,17 @@ /**

export class CoordinateSet extends Set {
constructor(joint?: string) {
super();
if (joint !== undefined) this._joint = joint;
}
protected _joint: string = '_';
get joint(): string {
return this._joint;
}
protected set joint(v: string) {
this._joint = v;
}
/**

@@ -20,11 +31,3 @@ * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.

}
protected set joint(v: string) {
this._joint = v;
}
constructor(joint?: string) {
super();
if (joint !== undefined) this._joint = joint;
}
/**

@@ -31,0 +34,0 @@ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after

@@ -12,31 +12,3 @@ /**

export abstract class Heap<T> {
protected abstract _pq: PriorityQueue<HeapItem<T>>;
get pq() {
return this._pq;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPq() {
return this._pq;
}
protected set pq(v: PriorityQueue<HeapItem<T>>) {
this._pq = v;
}
protected _priorityCb: (element: T) => number;
get priorityCb() {
return this._priorityCb;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPriorityCb() {
return this._priorityCb;
}
protected set priorityCb(v: (element: T) => number) {
this._priorityCb = v;
}
/**
* The function is a constructor for a class that initializes a priority callback function based on the

@@ -58,2 +30,21 @@ * options provided.

protected abstract _pq: PriorityQueue<HeapItem<T>>;
get pq() {
return this._pq;
}
protected set pq(v: PriorityQueue<HeapItem<T>>) {
this._pq = v;
}
protected _priorityCb: (element: T) => number;
get priorityCb() {
return this._priorityCb;
}
protected set priorityCb(v: (element: T) => number) {
this._priorityCb = v;
}
/**

@@ -66,5 +57,20 @@ * The function returns the size of a priority queue.

}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPq() {
return this._pq;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getPriorityCb() {
return this._priorityCb;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number {

@@ -71,0 +77,0 @@ return this._pq.size;

@@ -11,6 +11,14 @@ /**

export class DoublyLinkedListNode<T> {
constructor(nodeValue: T) {
this._val = nodeValue;
this._next = null;
this._prev = null;
}
protected _val: T;
get val(): T {
return this._val;
}
set val(v: T) {

@@ -21,5 +29,7 @@ this._val = v;

protected _next: DoublyLinkedListNode<T> | null;
get next(): DoublyLinkedListNode<T> | null {
return this._next;
}
set next(v: DoublyLinkedListNode<T> | null) {

@@ -30,27 +40,25 @@ this._next = v;

protected _prev: DoublyLinkedListNode<T> | null;
get prev(): DoublyLinkedListNode<T> | null {
return this._prev;
}
set prev(v: DoublyLinkedListNode<T> | null) {
this._prev = v;
}
}
constructor(nodeValue: T) {
this._val = nodeValue;
this._next = null;
this._prev = null;
export class DoublyLinkedList<T> {
constructor() {
this._first = null;
this._last = null;
this._size = 0;
}
}
export class DoublyLinkedList<T> {
protected _first: DoublyLinkedListNode<T> | null;
get first(): DoublyLinkedListNode<T> | null {
return this._first;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getFirst(): DoublyLinkedListNode<T> | null {
return this._first;
}
protected set first(v: DoublyLinkedListNode<T> | null) {

@@ -64,8 +72,3 @@ this._first = v;

}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLast(): DoublyLinkedListNode<T> | null {
return this._last;
}
protected set last(v: DoublyLinkedListNode<T> | null) {

@@ -76,19 +79,30 @@ this._last = v;

protected _size: number;
get size(): number {
return this._size;
}
protected set size(v: number) {
this._size = v;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number {
return this._size;
getFirst(): DoublyLinkedListNode<T> | null {
return this._first;
}
protected set size(v: number) {
this._size = v;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getLast(): DoublyLinkedListNode<T> | null {
return this._last;
}
constructor() {
this._first = null;
this._last = null;
this._size = 0;
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getSize(): number {
return this._size;
}

@@ -95,0 +109,0 @@

@@ -13,3 +13,11 @@ /**

export class SinglyLinkedListNode<NodeVal = any> {
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null) {
this._val = val;
this._prev = prev || null;
this._next = next || null;
this._list = list || null;
}
protected _val: NodeVal;
get val(): NodeVal {

@@ -24,2 +32,3 @@ return this._val;

protected _prev: SinglyLinkedListNode<NodeVal> | null;
get prev(): SinglyLinkedListNode<NodeVal> | null {

@@ -34,2 +43,3 @@ return this._prev;

protected _next: SinglyLinkedListNode<NodeVal> | null
get next(): SinglyLinkedListNode<NodeVal> | null {

@@ -44,2 +54,3 @@ return this._next;

protected _list: SinglyLinkedList<NodeVal> | null
get list(): SinglyLinkedList<NodeVal> | null {

@@ -53,9 +64,2 @@ return this._list;

constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null) {
this._val = val;
this._prev = prev || null;
this._next = next || null;
this._list = list || null;
}
get index() {

@@ -105,6 +109,23 @@ if (!this.list) {

/**
* The constructor initializes a linked list with the given arguments as nodes.
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
* arguments of type NodeVal.
*/
constructor(...args: NodeVal[]) {
this._head = null;
this._tail = null;
this._size = 0;
for (let i = 0; i < arguments.length; i++) {
this.append(args[i]);
}
}
protected _head: SinglyLinkedListNode<NodeVal> | null;
get head(): SinglyLinkedListNode<NodeVal> | null {
return this._head;
}
set head(value: SinglyLinkedListNode<NodeVal> | null) {

@@ -114,7 +135,8 @@ this._head = value;

protected _tail: SinglyLinkedListNode<NodeVal> | null;
protected _tail: SinglyLinkedListNode<NodeVal> | null;
get tail(): SinglyLinkedListNode<NodeVal> | null {
return this._tail;
}
set tail(value: SinglyLinkedListNode<NodeVal> | null) {

@@ -125,5 +147,7 @@ this._tail = value;

protected _size: number;
get size(): number {
return this._size;
}
set size(value: number) {

@@ -134,17 +158,2 @@ this._size = value;

/**
* The constructor initializes a linked list with the given arguments as nodes.
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
* arguments of type NodeVal.
*/
constructor(...args: NodeVal[]) {
this._head = null;
this._tail = null;
this._size = 0;
for (let i = 0; i < arguments.length; i++) {
this.append(args[i]);
}
}
/**
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.

@@ -151,0 +160,0 @@ * @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It

@@ -12,17 +12,3 @@ /**

protected _nodes: T[] = [];
get nodes(): T[] {
return this._nodes;
}
/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getNodes(): T[] {
return this._nodes;
}
protected set nodes(value: T[]) {
this._nodes = value;
}
/**
* The constructor initializes a priority queue with the given options, including an array of nodes and a comparator

@@ -43,2 +29,12 @@ * function.

protected _nodes: T[] = [];
get nodes(): T[] {
return this._nodes;
}
protected set nodes(value: T[]) {
this._nodes = value;
}
get size(): number {

@@ -73,2 +69,9 @@ return this.nodes.length;

/**
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
*/
getNodes(): T[] {
return this._nodes;
}
/**
* The "add" function adds a node to the heap and ensures that the heap property is maintained.

@@ -75,0 +78,0 @@ * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node

@@ -20,6 +20,12 @@ /**

export class ObjectDeque<T> {
constructor(capacity?: number) {
if (capacity !== undefined) this._capacity = capacity;
}
private _nodes: { [key: number]: T } = {};
get nodes(): { [p: number]: T } {
return this._nodes;
}
protected set nodes(value: { [p: number]: T }) {

@@ -30,5 +36,7 @@ this._nodes = value;

private _capacity = Number.MAX_SAFE_INTEGER;
get capacity(): number {
return this._capacity;
}
set capacity(value: number) {

@@ -39,5 +47,7 @@ this._capacity = value;

private _first: number = -1;
get first(): number {
return this._first;
}
set first(value: number) {

@@ -48,5 +58,7 @@ this._first = value;

private _last: number = -1;
get last(): number {
return this._last;
}
set last(value: number) {

@@ -57,5 +69,7 @@ this._last = value;

private _size: number = 0;
get size(): number {
return this._size;
}
protected set size(value: number) {

@@ -65,6 +79,2 @@ this._size = value;

constructor(capacity?: number) {
if (capacity !== undefined) this._capacity = capacity;
}
addFirst(value: T) {

@@ -71,0 +81,0 @@ if (this._size === 0) {

@@ -1,176 +0,4 @@

// export type JSONSerializable = {
// [key: string]: any
// }
// export type JSONValue = string | number | boolean | undefined | JSONObject;
//
// export interface JSONObject {
// [key: string]: JSONValue;
// }
//
// export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
// export type Primitive =
// | number
// | string
// | boolean
// | symbol
// | undefined
// | null
// | void
// | AnyFunction
// | Date;
// export type Cast<T, TComplex> = { [M in keyof TComplex]: T };
// export type DeepLeavesWrap<T, TComplex> =
// T extends string ? Cast<string, TComplex>
// : T extends number ? Cast<number, TComplex>
// : T extends boolean ? Cast<boolean, TComplex>
// : T extends undefined ? Cast<undefined, TComplex>
// : T extends null ? Cast<null, TComplex>
// : T extends void ? Cast<void, TComplex>
// : T extends symbol ? Cast<symbol, TComplex>
// : T extends AnyFunction ? Cast<AnyFunction, TComplex>
// : T extends Date ? Cast<Date, TComplex>
// : {
// [K in keyof T]:
// T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[]
// : DeepLeavesWrap<T[K], TComplex>;
// }
// type Json = null | string | number | boolean | Json [] | { [name: string]: Json }
// export type TypeName<T> = T extends string
// ? 'string'
// : T extends number
// ? 'number'
// : T extends boolean
// ? 'boolean'
// : T extends undefined
// ? 'undefined'
// : T extends AnyFunction
// ? 'function'
// : 'object';
// export type JsonKeys<T> = keyof {
// [P in keyof T]: number
// }
/**
* A function that emits a side effect and does not return anything.
*/
// export type Procedure = (...args: any[]) => void;
// export type DebounceOptions = {
// isImmediate?: boolean;
// maxWait?: number;
// };
// export interface DebouncedFunction<F extends Procedure> {
// cancel: () => void;
//
// (this: ThisParameterType<F>, ...args: [...Parameters<F>]): void;
// }
// export type MonthKey =
// 'January' |
// 'February' |
// 'March' |
// 'April' |
// 'May' |
// 'June' |
// 'July' |
// 'August' |
// 'September' |
// 'October' |
// 'November' |
// 'December';
// export type Month = { [key in MonthKey]: string }
// export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
// export class TreeNode<T> {
// id: string;
// name?: string | undefined;
// value?: T | undefined;
// children?: TreeNode<T>[] | undefined;
//
// constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]) {
// this.id = id;
// this.name = name || '';
// this.value = value || undefined;
// this.children = children || [];
// }
//
// addChildren(children: TreeNode<T> | TreeNode<T> []) {
// if (!this.children) {
// this.children = [];
// }
// if (children instanceof TreeNode) {
// this.children.push(children);
// } else {
// this.children = this.children.concat(children);
// }
// }
//
// getHeight() {
// // eslint-disable-next-line @typescript-eslint/no-this-alias
// const beginRoot = this;
// let maxDepth = 1;
// if (beginRoot) {
// const bfs = (node: TreeNode<T>, level: number) => {
// if (level > maxDepth) {
// maxDepth = level;
// }
// const {children} = node;
// if (children) {
// for (let i = 0, len = children.length; i < len; i++) {
// bfs(children[i], level + 1);
// }
// }
// };
// bfs(beginRoot, 1);
// }
// return maxDepth;
// }
//
// }
// export type OrderType = 'InOrder' | 'PreOrder' | 'PostOrder'
// export type DeepProxy<T> = T extends (...args: any[]) => infer R
// ? (...args: [...Parameters<T>]) => DeepProxy<R>
// : T extends object
// ? { [K in keyof T]: DeepProxy<T[K]> }
// : T;
// export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
// export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
// export type CurryFunc<T> = T extends (...args: infer Args) => infer R
// ? Args extends [infer Arg, ...infer RestArgs]
// ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R>
// : R
// : T;
export type ToThunkFn = () => ReturnType<TrlFn>;
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: Symbol };
export type TrlFn = (...args: any[]) => any;
export type TrlAsyncFn = (...args: any[]) => any;
// export type CaseType =
// 'camel'
// | 'snake'
// | 'pascal'
// | 'constant'
// | 'kebab'
// | 'lower'
// | 'title'
// | 'sentence'
// | 'path'
// | 'dot';
export type TrlAsyncFn = (...args: any[]) => any;

@@ -1,4 +0,1 @@

// import _ from 'lodash';
// import type {AnyFunction, CaseType, JSONObject, JSONSerializable} from './types';
export const uuidV4 = function () {

@@ -11,211 +8,2 @@ return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {

// export const isObject = (object: string | JSONObject | boolean | AnyFunction | number) => object != null && typeof object === 'object';
// export const deepObjectStrictEqual = (object1: JSONSerializable, object2: JSONSerializable) => {
// const keys1 = Object.keys(object1);
// const keys2 = Object.keys(object2);
// if (keys1.length !== keys2.length) {
// return false;
// }
// for (const key of keys1) {
// const val1 = object1[key];
// const val2 = object2[key];
// const areObjects = isObject(val1) && isObject(val2);
// if (
// areObjects && !deepObjectStrictEqual(val1, val2) ||
// !areObjects && val1 !== val2
// ) {
// return false;
// }
// }
// return true;
// };
// export class StringUtil {
// // camelCase
// static toCamelCase(str: string) {
// return _.camelCase(str);
// }
//
// // snake_case
// static toSnakeCase(str: string) {
// return _.snakeCase(str);
// }
//
// // PascalCase
// static toPascalCase(str: string) {
// return _.startCase(_.camelCase(str)).replace(/ /g, '');
// }
//
// // CONSTANT_CASE
// static toConstantCase(str: string) {
// return _.upperCase(str).replace(/ /g, '_');
// }
//
// // kebab-case
// static toKebabCase(str: string) {
// return _.kebabCase(str);
// }
//
// // lowercase
// static toLowerCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '');
// }
//
// // Title Case
// static toTitleCase(str: string) {
// return _.startCase(_.camelCase(str));
// }
//
// // Sentence case
// static toSentenceCase(str: string) {
// return _.upperFirst(_.lowerCase(str));
// }
//
// // path/case
// static toPathCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '/');
// }
//
// // dot.case
// static toDotCase(str: string) {
// return _.lowerCase(str).replace(/ /g, '.');
// }
// }
// export const deepKeysConvert = (obj: any, toType?: CaseType): any => {
// const _toType = toType || 'snake';
// if (Array.isArray(obj)) {
// return obj.map(v => deepKeysConvert(v, _toType));
// } else if (obj !== null && obj.constructor === Object) {
// return Object.keys(obj).reduce(
// (result, key) => {
// let newKey = '';
// switch (_toType) {
// case 'camel':
// newKey = StringUtil.toCamelCase(key);
// break;
// case 'snake':
// newKey = StringUtil.toSnakeCase(key);
// break;
// case 'pascal':
// newKey = StringUtil.toPascalCase(key);
// break;
// case 'constant':
// newKey = StringUtil.toConstantCase(key);
// break;
// case 'kebab':
// newKey = StringUtil.toKebabCase(key);
// break;
// case 'lower':
// newKey = StringUtil.toLowerCase(key);
// break;
// case 'title':
// newKey = StringUtil.toTitleCase(key);
// break;
// case 'sentence':
// newKey = StringUtil.toSentenceCase(key);
// break;
// case 'path':
// newKey = StringUtil.toPathCase(key);
// break;
// case 'dot':
// newKey = StringUtil.toDotCase(key);
// break;
// default:
// newKey = StringUtil.toDotCase(key);
// break;
// }
// return {
// ...result,
// [newKey]: deepKeysConvert(obj[key], _toType),
// };
// },
// {},
// );
// }
// return obj;
// };
// export const deepRemoveByKey = (obj: any, keysToBeRemoved: string[]) => {
// const result = _.transform(obj, function (result: JSONSerializable, value: any, key: string) {
// if (_.isObject(value)) {
// value = deepRemoveByKey(value, keysToBeRemoved);
// }
// if (!keysToBeRemoved.includes(key)) {
// _.isArray(obj) ? result.push(value) : result[key] = value;
// }
// });
// return result as typeof obj;
// };
// export const deepRenameKeys = (obj: JSONSerializable, keysMap: { [key in string]: string }) => {
// return _.transform(obj, function (result: JSONSerializable, value: any, key: string | number) {
// const currentKey = keysMap[key] || key;
// result[currentKey] = _.isObject(value) ? deepRenameKeys(value, keysMap) : value;
// });
// };
// export const deepReplaceValues = (obj: JSONSerializable, keyReducerMap: { [key in string]: (item: JSONSerializable) => any }) => {
// const newObject = _.clone(obj) as JSONSerializable;
// _.each(obj, (val: any, key: string) => {
// for (const item in keyReducerMap) {
// if (key === item) {
// newObject[key] = keyReducerMap[item](newObject);
// } else if (typeof (val) === 'object' || val instanceof Array) {
// newObject[key] = deepReplaceValues(val, keyReducerMap);
// }
// }
// });
// return newObject;
// };
// TODO determine depth and pass root node as a param through callback
// export const deepAdd = (obj: JSONSerializable, keyReducerMap: { [key in string]: (item: JSONSerializable) => any }, isItemRootParent?: boolean) => {
// const newObject = _.clone(obj) as JSONObject | [];
// if (_.isObject(newObject) && !_.isArray(newObject)) {
// for (const item in keyReducerMap) {
// newObject[item] = keyReducerMap[item](newObject);
// }
// }
// _.each(obj, (val: any, key: string | number) => {
// if (_.isObject(val)) {
// for (const item in keyReducerMap) {
// // @ts-ignore
// newObject[key] = deepAdd(val, keyReducerMap, isItemRootParent);
// }
// }
// });
// return newObject;
// };
// const styleString = (color: string) => `color: ${color}; font-weight: bold`;
// const styleHeader = (header: string) => `%c[${header}]`;
// export const bunnyConsole = {
// log: (headerLog = 'bunny', ...args: any[]) => {
// return console.log(styleHeader(headerLog), styleString('black'), ...args);
// },
// warn: (headerLog = 'bunny', ...args: any[]) => {
// return console.warn(styleHeader(headerLog), styleString('orange'), ...args);
// },
// error: (headerLog = 'bunny', ...args: any[]) => {
// return console.error(styleHeader(headerLog), styleString('red'), ...args);
// }
// };
// export const timeStart = () => {
// return performance ? performance.now() : new Date().getTime();
// };
// export const timeEnd = (startTime: number, headerLog?: string, consoleConditionFn?: (timeSpent: number) => boolean) => {
// const timeSpent = (performance ? performance.now() : new Date().getTime()) - startTime;
// const isPassCondition = consoleConditionFn ? consoleConditionFn(timeSpent) : true;
// if (isPassCondition) {
// bunnyConsole.log(headerLog ? headerLog : 'time spent', timeSpent.toFixed(2));
// }
// };
export const arrayRemove = function <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean): T[] {

@@ -222,0 +10,0 @@ let i = -1, len = array ? array.length : 0;

import {BST, BSTNode} from '../../../../src';
describe('bst-case6', () => {
describe('BST Case6', () => {
it('should perform various operations on a Binary Search Tree', () => {
const arr = [11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
const tree = new BST();
expect(tree).toBeInstanceOf(BST);
tree.addMany(arr);
const values = [11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
tree.addMany(values);
expect(tree.root).toBeInstanceOf(BSTNode);
expect(tree.root).toBeInstanceOf(BSTNode);
if (tree.root) expect(tree.root.id).toBe(11);
expect(tree.count).toBe(16);
expect(tree.has(6)).toBe(true);

@@ -21,14 +22,18 @@

expect(node6 && tree.getDepth(node6)).toBe(3);
const getNodeById = tree.get(10, 'id');
expect(getNodeById?.id).toBe(10);
const getNodesByCount = tree.getNodes(1, 'count');
expect(getNodesByCount.length).toBe(16);
const nodeId10 = tree.get(10, 'id');
expect(nodeId10?.id).toBe(10);
const getMinNodeByRoot = tree.getLeftMost();
expect(getMinNodeByRoot?.id).toBe(1);
const nodeVal9 = tree.get(9, 'val');
expect(nodeVal9?.id).toBe(9);
const nodesByCount1 = tree.getNodes(1, 'count');
expect(nodesByCount1.length).toBe(16);
const leftMost = tree.getLeftMost();
expect(leftMost?.id).toBe(1);
const node15 = tree.get(15);
const getMinNodeBySpecificNode = node15 && tree.getLeftMost(node15);
expect(getMinNodeBySpecificNode?.id).toBe(12);
const minNodeBySpecificNode = node15 && tree.getLeftMost(node15);
expect(minNodeBySpecificNode?.id).toBe(12);

@@ -47,20 +52,20 @@ const subTreeSum = node15 && tree.subTreeSum(node15);

const node11 = tree.get(11);
expect(node11).toBeInstanceOf(BSTNode);
if (node11 instanceof BSTNode) {
const allGreaterNodesAdd = tree.allGreaterNodesAdd(node11, 2, 'count');
expect(allGreaterNodesAdd).toBeDefined();
const allGreaterNodesAdded = tree.allGreaterNodesAdd(node11, 2, 'count');
expect(allGreaterNodesAdded).toBeDefined();
}
const dfs = tree.DFS('in', 'node');
expect(dfs[0].id).toBe(1);
expect(dfs[dfs.length - 1].id).toBe(16);
const dfsInorderNodes = tree.DFS('in', 'node');
expect(dfsInorderNodes[0].id).toBe(1);
expect(dfsInorderNodes[dfsInorderNodes.length - 1].id).toBe(16);
tree.balance();
const bfs = tree.BFS('node');
expect(tree.isBalanced()).toBe(true);
expect(bfs[0].id).toBe(8);
expect(bfs[bfs.length - 1].id).toBe(16);
const bfsNodesAfterBalanced = tree.BFS('node');
expect(bfsNodesAfterBalanced[0].id).toBe(8);
expect(bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].id).toBe(16);
const removed11 = tree.remove(11, true);

@@ -70,4 +75,7 @@ expect(removed11).toBeInstanceOf(Array);

expect(removed11[0].deleted).toBeDefined();
if (removed11[0].deleted) expect(removed11[0].deleted.id).toBe(11);
expect(tree.isAVLBalanced()).toBe(true);
expect(node15 && tree.getHeight(node15)).toBe(2);

@@ -82,2 +90,3 @@

expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(4);

@@ -177,14 +186,14 @@

expect(!tree.isAVLBalanced()).toBe(true);
expect(tree.isAVLBalanced()).toBe(false);
const lastBFSIds = tree.BFS();
expect(lastBFSIds[0]).toBe(2);
expect(lastBFSIds[1]).toBe(12);
expect(lastBFSIds[2]).toBe(16);
const bfsIDs = tree.BFS();
expect(bfsIDs[0]).toBe(2);
expect(bfsIDs[1]).toBe(12);
expect(bfsIDs[2]).toBe(16);
const lastBFSNodes = tree.BFS('node');
expect(lastBFSNodes[0].id).toBe(2);
expect(lastBFSNodes[1].id).toBe(12);
expect(lastBFSNodes[2].id).toBe(16);
const bfsNodes = tree.BFS('node');
expect(bfsNodes[0].id).toBe(2);
expect(bfsNodes[1].id).toBe(12);
expect(bfsNodes[2].id).toBe(16);
});
});
import {DirectedEdge, DirectedGraph, DirectedVertex, VertexId} from '../../../../src';
class MyVertex extends DirectedVertex {
data: string;
constructor(id: VertexId, data: string) {
super(id);
this.data = data;
}
}
class MyEdge extends DirectedEdge {
data: string;
constructor(v1: VertexId, v2: VertexId, weight: number, data: string) {
super(v1, v2, weight);
this.data = data;
}
}
class MyGraph<V extends MyVertex, E extends MyEdge> extends DirectedGraph<V, E> {
constructor() {
super();
}
}
describe('DirectedGraph Test1', () => {

@@ -72,6 +48,3 @@ let graph: DirectedGraph<DirectedVertex, DirectedEdge>;

// Add more test cases for other methods...
it('should perform topological sort', () => {
// Create a graph with vertices and edges
const vertexA = new DirectedVertex('A');

@@ -89,13 +62,39 @@ const vertexB = new DirectedVertex('B');

// Perform topological sort
const topologicalOrder = graph.topologicalSort();
if (topologicalOrder) expect(topologicalOrder.map(v => v.id)).toEqual(['A', 'B', 'C']);
});
// Add more test cases for other methods...
});
class MyVertex extends DirectedVertex {
private _data: string;
get data(): string {
return this._data;
}
set data(value: string) {
this._data = value;
}
constructor(id: VertexId, data: string) {
super(id);
this._data = data;
}
}
class MyEdge extends DirectedEdge {
private _data: string;
get data(): string {
return this._data;
}
set data(value: string) {
this._data = value;
}
constructor(v1: VertexId, v2: VertexId, weight: number, data: string) {
super(v1, v2, weight);
this._data = data;
}
}
describe('DirectedGraph Test2 operations', () => {

@@ -228,4 +227,2 @@ const myGraph = new DirectedGraph<MyVertex, MyEdge>();

// Add the rest of your assertions here...
myGraph.removeEdgeBetween(1, 2);

@@ -232,0 +229,0 @@ expect(myGraph.getEdge(1, 2)).toBeFalsy();

Sorry, the diff of this file is too big to display

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