From 450f051138cfe2bc71589507ca9ea509d998fe6b Mon Sep 17 00:00:00 2001 From: Revone Date: Tue, 12 Sep 2023 11:10:09 +0800 Subject: [PATCH] Optimize the overall codebase and directory structure. --- README.md | 4 ++-- src/data-structures/binary-tree/abstract-binary-tree.ts | 6 +++--- src/data-structures/binary-tree/avl-tree.ts | 4 ++-- src/data-structures/binary-tree/binary-tree.ts | 4 ++-- src/data-structures/binary-tree/bst.ts | 6 +++--- src/data-structures/binary-tree/rb-tree.ts | 4 ++-- src/data-structures/binary-tree/segment-tree.ts | 2 +- src/data-structures/binary-tree/tree-multiset.ts | 6 +++--- src/data-structures/graph/abstract-graph.ts | 4 ++-- src/data-structures/graph/directed-graph.ts | 4 ++-- src/data-structures/graph/map-graph.ts | 2 +- src/data-structures/graph/undirected-graph.ts | 4 ++-- src/data-structures/heap/heap.ts | 2 +- src/data-structures/heap/max-heap.ts | 2 +- src/data-structures/heap/min-heap.ts | 2 +- src/data-structures/index.ts | 6 +----- src/data-structures/matrix/navigator.ts | 2 +- src/data-structures/priority-queue/max-priority-queue.ts | 3 +-- src/data-structures/priority-queue/min-priority-queue.ts | 3 +-- src/data-structures/priority-queue/priority-queue.ts | 2 +- src/index.ts | 4 +++- .../interfaces/abstract-binary-tree.ts | 2 +- src/{data-structures => }/interfaces/abstract-graph.ts | 8 -------- src/{data-structures => }/interfaces/avl-tree.ts | 2 +- src/{data-structures => }/interfaces/binary-tree.ts | 2 +- src/{data-structures => }/interfaces/bst.ts | 2 +- src/{data-structures => }/interfaces/directed-graph.ts | 0 .../interfaces/doubly-linked-list.ts | 0 src/{data-structures => }/interfaces/heap.ts | 0 src/{data-structures => }/interfaces/index.ts | 0 src/{data-structures => }/interfaces/navigator.ts | 0 src/{data-structures => }/interfaces/priority-queue.ts | 0 src/{data-structures => }/interfaces/rb-tree.ts | 2 +- src/{data-structures => }/interfaces/segment-tree.ts | 0 .../interfaces/singly-linked-list.ts | 0 src/{data-structures => }/interfaces/tree-multiset.ts | 2 +- src/{data-structures => }/interfaces/undirected-graph.ts | 0 .../data-structures}/abstract-binary-tree.ts | 2 +- .../types => types/data-structures}/abstract-graph.ts | 0 .../types => types/data-structures}/avl-tree.ts | 2 +- .../types => types/data-structures}/binary-tree.ts | 2 +- .../types => types/data-structures}/bst.ts | 2 +- .../types => types/data-structures}/directed-graph.ts | 0 .../types => types/data-structures}/doubly-linked-list.ts | 0 .../types => types/data-structures}/heap.ts | 0 .../types => types/data-structures}/index.ts | 3 +-- .../types => types/data-structures}/map-graph.ts | 0 .../types => types/data-structures}/navigator.ts | 0 .../types => types/data-structures}/priority-queue.ts | 0 .../types => types/data-structures}/rb-tree.ts | 2 +- .../types => types/data-structures}/segment-tree.ts | 0 .../types => types/data-structures}/singly-linked-list.ts | 0 .../types => types/data-structures}/tree-multiset.ts | 2 +- src/{data-structures => }/types/helpers.ts | 0 src/types/index.ts | 3 +++ src/{utils/types => types/utils}/index.ts | 0 src/{utils/types => types/utils}/utils.ts | 0 src/{utils/types => types/utils}/validate-type.ts | 0 src/utils/index.ts | 1 - src/utils/utils.ts | 2 +- src/utils/validate-type.ts | 2 +- 61 files changed, 54 insertions(+), 65 deletions(-) rename src/{data-structures => }/interfaces/abstract-binary-tree.ts (98%) rename src/{data-structures => }/interfaces/abstract-graph.ts (81%) rename src/{data-structures => }/interfaces/avl-tree.ts (93%) rename src/{data-structures => }/interfaces/binary-tree.ts (86%) rename src/{data-structures => }/interfaces/bst.ts (96%) rename src/{data-structures => }/interfaces/directed-graph.ts (100%) rename src/{data-structures => }/interfaces/doubly-linked-list.ts (100%) rename src/{data-structures => }/interfaces/heap.ts (100%) rename src/{data-structures => }/interfaces/index.ts (100%) rename src/{data-structures => }/interfaces/navigator.ts (100%) rename src/{data-structures => }/interfaces/priority-queue.ts (100%) rename src/{data-structures => }/interfaces/rb-tree.ts (87%) rename src/{data-structures => }/interfaces/segment-tree.ts (100%) rename src/{data-structures => }/interfaces/singly-linked-list.ts (100%) rename src/{data-structures => }/interfaces/tree-multiset.ts (84%) rename src/{data-structures => }/interfaces/undirected-graph.ts (100%) rename src/{data-structures/types => types/data-structures}/abstract-binary-tree.ts (97%) rename src/{data-structures/types => types/data-structures}/abstract-graph.ts (100%) rename src/{data-structures/types => types/data-structures}/avl-tree.ts (93%) rename src/{data-structures/types => types/data-structures}/binary-tree.ts (95%) rename src/{data-structures/types => types/data-structures}/bst.ts (94%) rename src/{data-structures/types => types/data-structures}/directed-graph.ts (100%) rename src/{data-structures/types => types/data-structures}/doubly-linked-list.ts (100%) rename src/{data-structures/types => types/data-structures}/heap.ts (100%) rename src/{data-structures/types => types/data-structures}/index.ts (89%) rename src/{data-structures/types => types/data-structures}/map-graph.ts (100%) rename src/{data-structures/types => types/data-structures}/navigator.ts (100%) rename src/{data-structures/types => types/data-structures}/priority-queue.ts (100%) rename src/{data-structures/types => types/data-structures}/rb-tree.ts (93%) rename src/{data-structures/types => types/data-structures}/segment-tree.ts (100%) rename src/{data-structures/types => types/data-structures}/singly-linked-list.ts (100%) rename src/{data-structures/types => types/data-structures}/tree-multiset.ts (94%) rename src/{data-structures => }/types/helpers.ts (100%) create mode 100644 src/types/index.ts rename src/{utils/types => types/utils}/index.ts (100%) rename src/{utils/types => types/utils}/utils.ts (100%) rename src/{utils/types => types/utils}/validate-type.ts (100%) diff --git a/README.md b/README.md index 451397d..5101700 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> ## install ### npm ```bash -npm install data-structure-typed --save +npm install data-structure-typed ``` ### yarn ```bash -yarn add data-structure-typed -D +yarn add data-structure-typed ``` ### CDN ```html diff --git a/src/data-structures/binary-tree/abstract-binary-tree.ts b/src/data-structures/binary-tree/abstract-binary-tree.ts index 6be277b..ef34d19 100644 --- a/src/data-structures/binary-tree/abstract-binary-tree.ts +++ b/src/data-structures/binary-tree/abstract-binary-tree.ts @@ -16,9 +16,9 @@ import type { BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName -} from '../types'; -import {AbstractBinaryTreeOptions, FamilyPosition, LoopType} from '../types'; -import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from '../interfaces'; +} from '../../types'; +import {AbstractBinaryTreeOptions, FamilyPosition, LoopType} from '../../types'; +import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from '../../interfaces'; export abstract class AbstractBinaryTreeNode = AbstractBinaryTreeNodeNested> implements IAbstractBinaryTreeNode { diff --git a/src/data-structures/binary-tree/avl-tree.ts b/src/data-structures/binary-tree/avl-tree.ts index 2d14c18..a568356 100644 --- a/src/data-structures/binary-tree/avl-tree.ts +++ b/src/data-structures/binary-tree/avl-tree.ts @@ -6,8 +6,8 @@ * @license MIT License */ import {BST, BSTNode} from './bst'; -import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types'; -import {IAVLTree, IAVLTreeNode} from '../interfaces'; +import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId} from '../../types'; +import {IAVLTree, IAVLTreeNode} from '../../interfaces'; export class AVLTreeNode = AVLTreeNodeNested> extends BSTNode implements IAVLTreeNode { constructor(id: BinaryTreeNodeId, val?: T) { diff --git a/src/data-structures/binary-tree/binary-tree.ts b/src/data-structures/binary-tree/binary-tree.ts index f7ffa17..725716f 100644 --- a/src/data-structures/binary-tree/binary-tree.ts +++ b/src/data-structures/binary-tree/binary-tree.ts @@ -6,9 +6,9 @@ * @license MIT License */ -import type {BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions} from '../types'; +import type {BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions} from '../../types'; import {AbstractBinaryTree, AbstractBinaryTreeNode} from './abstract-binary-tree'; -import {IBinaryTree, IBinaryTreeNode} from '../interfaces'; +import {IBinaryTree, IBinaryTreeNode} from '../../interfaces'; export class BinaryTreeNode = BinaryTreeNodeNested> extends AbstractBinaryTreeNode implements IBinaryTreeNode { constructor(id: BinaryTreeNodeId, val?: T) { diff --git a/src/data-structures/binary-tree/bst.ts b/src/data-structures/binary-tree/bst.ts index 47862c5..6934be3 100644 --- a/src/data-structures/binary-tree/bst.ts +++ b/src/data-structures/binary-tree/bst.ts @@ -5,10 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions} from '../types'; -import {CP, LoopType} from '../types'; +import type {BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions} from '../../types'; +import {CP, LoopType} from '../../types'; import {BinaryTree, BinaryTreeNode} from './binary-tree'; -import {IBST, IBSTNode} from '../interfaces'; +import {IBST, IBSTNode} from '../../interfaces'; export class BSTNode = BSTNodeNested> extends BinaryTreeNode implements IBSTNode { constructor(id: BinaryTreeNodeId, val?: T) { diff --git a/src/data-structures/binary-tree/rb-tree.ts b/src/data-structures/binary-tree/rb-tree.ts index d404ac7..298171e 100644 --- a/src/data-structures/binary-tree/rb-tree.ts +++ b/src/data-structures/binary-tree/rb-tree.ts @@ -1,5 +1,5 @@ -import {BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions} from '../types'; -import {IRBTree, IRBTreeNode} from '../interfaces/rb-tree'; +import {BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions} from '../../types'; +import {IRBTree, IRBTreeNode} from '../../interfaces/rb-tree'; import {BST, BSTNode} from './bst'; diff --git a/src/data-structures/binary-tree/segment-tree.ts b/src/data-structures/binary-tree/segment-tree.ts index e88e4a6..5d8f5a7 100644 --- a/src/data-structures/binary-tree/segment-tree.ts +++ b/src/data-structures/binary-tree/segment-tree.ts @@ -6,7 +6,7 @@ * @license MIT License */ -import type {SegmentTreeNodeVal} from '../types'; +import type {SegmentTreeNodeVal} from '../../types'; export class SegmentTreeNode { constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null) { diff --git a/src/data-structures/binary-tree/tree-multiset.ts b/src/data-structures/binary-tree/tree-multiset.ts index 28d56d9..d3ebca9 100644 --- a/src/data-structures/binary-tree/tree-multiset.ts +++ b/src/data-structures/binary-tree/tree-multiset.ts @@ -5,9 +5,9 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions} from '../types'; -import {BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName} from '../types'; -import {ITreeMultiset, ITreeMultisetNode} from '../interfaces'; +import type {BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types'; +import {BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName} from '../../types'; +import {ITreeMultiset, ITreeMultisetNode} from '../../interfaces'; import {AVLTree, AVLTreeNode} from './avl-tree'; export class TreeMultisetNode = TreeMultisetNodeNested> extends AVLTreeNode implements ITreeMultisetNode { diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index 3634a35..cc75bb8 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -7,8 +7,8 @@ */ import {arrayRemove, uuidV4} from '../../utils'; import {PriorityQueue} from '../priority-queue'; -import type {DijkstraResult, VertexId} from '../types'; -import {IAbstractGraph} from '../interfaces'; +import type {DijkstraResult, VertexId} from '../../types'; +import {IAbstractGraph} from '../../interfaces'; export abstract class AbstractVertex { diff --git a/src/data-structures/graph/directed-graph.ts b/src/data-structures/graph/directed-graph.ts index 0fdae40..834347d 100644 --- a/src/data-structures/graph/directed-graph.ts +++ b/src/data-structures/graph/directed-graph.ts @@ -7,8 +7,8 @@ */ import {arrayRemove} from '../../utils'; import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph'; -import type {TopologicalStatus, VertexId} from '../types'; -import {IDirectedGraph} from '../interfaces'; +import type {TopologicalStatus, VertexId} from '../../types'; +import {IDirectedGraph} from '../../interfaces'; export class DirectedVertex extends AbstractVertex { /** diff --git a/src/data-structures/graph/map-graph.ts b/src/data-structures/graph/map-graph.ts index 5f350aa..530409d 100644 --- a/src/data-structures/graph/map-graph.ts +++ b/src/data-structures/graph/map-graph.ts @@ -1,4 +1,4 @@ -import {MapGraphCoordinate, VertexId} from '../types'; +import {MapGraphCoordinate, VertexId} from '../../types'; import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph'; export class MapVertex extends DirectedVertex { diff --git a/src/data-structures/graph/undirected-graph.ts b/src/data-structures/graph/undirected-graph.ts index bd05ada..8c106e3 100644 --- a/src/data-structures/graph/undirected-graph.ts +++ b/src/data-structures/graph/undirected-graph.ts @@ -7,8 +7,8 @@ */ import {arrayRemove} from '../../utils'; import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph'; -import type {VertexId} from '../types'; -import {IUNDirectedGraph} from '../interfaces'; +import type {VertexId} from '../../types'; +import {IUNDirectedGraph} from '../../interfaces'; export class UndirectedVertex extends AbstractVertex { /** diff --git a/src/data-structures/heap/heap.ts b/src/data-structures/heap/heap.ts index 37eac63..a049231 100644 --- a/src/data-structures/heap/heap.ts +++ b/src/data-structures/heap/heap.ts @@ -6,7 +6,7 @@ * @license MIT License */ import {PriorityQueue} from '../priority-queue'; -import type {HeapOptions} from '../types'; +import type {HeapOptions} from '../../types'; export class HeapItem { diff --git a/src/data-structures/heap/max-heap.ts b/src/data-structures/heap/max-heap.ts index 983b4a5..8b747d1 100644 --- a/src/data-structures/heap/max-heap.ts +++ b/src/data-structures/heap/max-heap.ts @@ -8,7 +8,7 @@ import {Heap, HeapItem} from './heap'; import {PriorityQueue} from '../priority-queue'; -import type {HeapOptions} from '../types'; +import type {HeapOptions} from '../../types'; /** * @class MaxHeap diff --git a/src/data-structures/heap/min-heap.ts b/src/data-structures/heap/min-heap.ts index 189234a..e3b64d0 100644 --- a/src/data-structures/heap/min-heap.ts +++ b/src/data-structures/heap/min-heap.ts @@ -8,7 +8,7 @@ import {Heap, HeapItem} from './heap'; import {PriorityQueue} from '../priority-queue'; -import type {HeapOptions} from '../types'; +import type {HeapOptions} from '../../types'; /** * @class MinHeap diff --git a/src/data-structures/index.ts b/src/data-structures/index.ts index 9dfa0b2..f9e32cc 100644 --- a/src/data-structures/index.ts +++ b/src/data-structures/index.ts @@ -8,8 +8,4 @@ export * from './tree'; export * from './heap'; export * from './priority-queue'; export * from './matrix'; -export * from './trie'; -export * from './interfaces'; -export * from './types'; - - +export * from './trie'; \ No newline at end of file diff --git a/src/data-structures/matrix/navigator.ts b/src/data-structures/matrix/navigator.ts index fd6a42e..a76d0ef 100644 --- a/src/data-structures/matrix/navigator.ts +++ b/src/data-structures/matrix/navigator.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {Direction, NavigatorParams, Turning} from '../types'; +import type {Direction, NavigatorParams, Turning} from '../../types'; export class Character { direction: Direction; diff --git a/src/data-structures/priority-queue/max-priority-queue.ts b/src/data-structures/priority-queue/max-priority-queue.ts index 97a63e0..2d3f85b 100644 --- a/src/data-structures/priority-queue/max-priority-queue.ts +++ b/src/data-structures/priority-queue/max-priority-queue.ts @@ -6,8 +6,7 @@ * @license MIT License */ import {PriorityQueue} from './priority-queue'; -import type {PriorityQueueOptions} from '../types'; -import {SpecifyOptional} from '../../utils'; +import type {PriorityQueueOptions, SpecifyOptional} from '../../types'; export class MaxPriorityQueue extends PriorityQueue { constructor(options?: Omit, 'comparator'>) diff --git a/src/data-structures/priority-queue/min-priority-queue.ts b/src/data-structures/priority-queue/min-priority-queue.ts index 933c819..dc0d591 100644 --- a/src/data-structures/priority-queue/min-priority-queue.ts +++ b/src/data-structures/priority-queue/min-priority-queue.ts @@ -6,8 +6,7 @@ * @license MIT License */ import {PriorityQueue} from './priority-queue'; -import type {PriorityQueueOptions} from '../types'; -import {SpecifyOptional} from '../../utils'; +import type {PriorityQueueOptions, SpecifyOptional} from '../../types'; export class MinPriorityQueue extends PriorityQueue { constructor(options?: Omit, 'comparator'>) diff --git a/src/data-structures/priority-queue/priority-queue.ts b/src/data-structures/priority-queue/priority-queue.ts index 9470ea5..59a8190 100644 --- a/src/data-structures/priority-queue/priority-queue.ts +++ b/src/data-structures/priority-queue/priority-queue.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions} from '../types'; +import type {PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions} from '../../types'; export class PriorityQueue { /** diff --git a/src/index.ts b/src/index.ts index 728b3cd..b315278 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,4 @@ export * from './data-structures'; -export * from './utils'; \ No newline at end of file +export * from './utils'; +export * from './interfaces'; +export * from './types'; \ No newline at end of file diff --git a/src/data-structures/interfaces/abstract-binary-tree.ts b/src/interfaces/abstract-binary-tree.ts similarity index 98% rename from src/data-structures/interfaces/abstract-binary-tree.ts rename to src/interfaces/abstract-binary-tree.ts index fed8df7..09f376c 100644 --- a/src/data-structures/interfaces/abstract-binary-tree.ts +++ b/src/interfaces/abstract-binary-tree.ts @@ -9,7 +9,7 @@ import { LoopType, NodeOrPropertyName } from '../types'; -import {AbstractBinaryTreeNode} from '../binary-tree'; +import {AbstractBinaryTreeNode} from '../data-structures'; export interface IAbstractBinaryTreeNode> { diff --git a/src/data-structures/interfaces/abstract-graph.ts b/src/interfaces/abstract-graph.ts similarity index 81% rename from src/data-structures/interfaces/abstract-graph.ts rename to src/interfaces/abstract-graph.ts index fd895b5..59e9720 100644 --- a/src/data-structures/interfaces/abstract-graph.ts +++ b/src/interfaces/abstract-graph.ts @@ -4,14 +4,8 @@ export interface IAbstractGraph { hasVertex(vertexOrId: V | VertexId): boolean; - // _getVertex(vertexOrId: VertexId | V): V | null; - - // _getVertexId(vertexOrId: V | VertexId): VertexId; - addVertex(id: VertexId, val?: V): boolean; - // _addVertexOnly(newVertex: V): boolean; - removeVertex(vertexOrId: V | VertexId): boolean; removeAllVertices(vertices: V[] | VertexId[]): boolean; @@ -28,8 +22,6 @@ export interface IAbstractGraph { addEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean; - // _addEdgeOnly(edge: E): boolean; - removeEdge(edge: E): E | null; setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean; diff --git a/src/data-structures/interfaces/avl-tree.ts b/src/interfaces/avl-tree.ts similarity index 93% rename from src/data-structures/interfaces/avl-tree.ts rename to src/interfaces/avl-tree.ts index dbe7692..c2b4fda 100644 --- a/src/data-structures/interfaces/avl-tree.ts +++ b/src/interfaces/avl-tree.ts @@ -1,4 +1,4 @@ -import {AVLTreeNode} from '../binary-tree'; +import {AVLTreeNode} from '../data-structures'; import {IBST, IBSTNode} from './bst'; import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types'; diff --git a/src/data-structures/interfaces/binary-tree.ts b/src/interfaces/binary-tree.ts similarity index 86% rename from src/data-structures/interfaces/binary-tree.ts rename to src/interfaces/binary-tree.ts index d78f3a9..f690600 100644 --- a/src/data-structures/interfaces/binary-tree.ts +++ b/src/interfaces/binary-tree.ts @@ -1,4 +1,4 @@ -import {BinaryTreeNode} from '../binary-tree'; +import {BinaryTreeNode} from '../data-structures'; import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree'; export interface IBinaryTreeNode> extends IAbstractBinaryTreeNode { diff --git a/src/data-structures/interfaces/bst.ts b/src/interfaces/bst.ts similarity index 96% rename from src/data-structures/interfaces/bst.ts rename to src/interfaces/bst.ts index 43c8c0a..c2d888a 100644 --- a/src/data-structures/interfaces/bst.ts +++ b/src/interfaces/bst.ts @@ -1,4 +1,4 @@ -import {BSTNode} from '../binary-tree'; +import {BSTNode} from '../data-structures'; import {IBinaryTree, IBinaryTreeNode} from './binary-tree'; import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types'; diff --git a/src/data-structures/interfaces/directed-graph.ts b/src/interfaces/directed-graph.ts similarity index 100% rename from src/data-structures/interfaces/directed-graph.ts rename to src/interfaces/directed-graph.ts diff --git a/src/data-structures/interfaces/doubly-linked-list.ts b/src/interfaces/doubly-linked-list.ts similarity index 100% rename from src/data-structures/interfaces/doubly-linked-list.ts rename to src/interfaces/doubly-linked-list.ts diff --git a/src/data-structures/interfaces/heap.ts b/src/interfaces/heap.ts similarity index 100% rename from src/data-structures/interfaces/heap.ts rename to src/interfaces/heap.ts diff --git a/src/data-structures/interfaces/index.ts b/src/interfaces/index.ts similarity index 100% rename from src/data-structures/interfaces/index.ts rename to src/interfaces/index.ts diff --git a/src/data-structures/interfaces/navigator.ts b/src/interfaces/navigator.ts similarity index 100% rename from src/data-structures/interfaces/navigator.ts rename to src/interfaces/navigator.ts diff --git a/src/data-structures/interfaces/priority-queue.ts b/src/interfaces/priority-queue.ts similarity index 100% rename from src/data-structures/interfaces/priority-queue.ts rename to src/interfaces/priority-queue.ts diff --git a/src/data-structures/interfaces/rb-tree.ts b/src/interfaces/rb-tree.ts similarity index 87% rename from src/data-structures/interfaces/rb-tree.ts rename to src/interfaces/rb-tree.ts index a2dc2a3..f6e0859 100644 --- a/src/data-structures/interfaces/rb-tree.ts +++ b/src/interfaces/rb-tree.ts @@ -1,4 +1,4 @@ -import {RBTreeNode} from '../binary-tree'; +import {RBTreeNode} from '../data-structures'; import {IBST, IBSTNode} from './bst'; import {BinaryTreeNodeId} from '../types'; diff --git a/src/data-structures/interfaces/segment-tree.ts b/src/interfaces/segment-tree.ts similarity index 100% rename from src/data-structures/interfaces/segment-tree.ts rename to src/interfaces/segment-tree.ts diff --git a/src/data-structures/interfaces/singly-linked-list.ts b/src/interfaces/singly-linked-list.ts similarity index 100% rename from src/data-structures/interfaces/singly-linked-list.ts rename to src/interfaces/singly-linked-list.ts diff --git a/src/data-structures/interfaces/tree-multiset.ts b/src/interfaces/tree-multiset.ts similarity index 84% rename from src/data-structures/interfaces/tree-multiset.ts rename to src/interfaces/tree-multiset.ts index 64a4267..5279cd4 100644 --- a/src/data-structures/interfaces/tree-multiset.ts +++ b/src/interfaces/tree-multiset.ts @@ -1,4 +1,4 @@ -import {TreeMultisetNode} from '../binary-tree'; +import {TreeMultisetNode} from '../data-structures'; import {IBSTNode} from './bst'; import {IAVLTree} from './avl-tree'; diff --git a/src/data-structures/interfaces/undirected-graph.ts b/src/interfaces/undirected-graph.ts similarity index 100% rename from src/data-structures/interfaces/undirected-graph.ts rename to src/interfaces/undirected-graph.ts diff --git a/src/data-structures/types/abstract-binary-tree.ts b/src/types/data-structures/abstract-binary-tree.ts similarity index 97% rename from src/data-structures/types/abstract-binary-tree.ts rename to src/types/data-structures/abstract-binary-tree.ts index 4188ba8..4376d92 100644 --- a/src/data-structures/types/abstract-binary-tree.ts +++ b/src/types/data-structures/abstract-binary-tree.ts @@ -1,4 +1,4 @@ -import {AbstractBinaryTreeNode} from '../binary-tree'; +import {AbstractBinaryTreeNode} from '../../data-structures/binary-tree'; /** * Enum representing different loop types. diff --git a/src/data-structures/types/abstract-graph.ts b/src/types/data-structures/abstract-graph.ts similarity index 100% rename from src/data-structures/types/abstract-graph.ts rename to src/types/data-structures/abstract-graph.ts diff --git a/src/data-structures/types/avl-tree.ts b/src/types/data-structures/avl-tree.ts similarity index 93% rename from src/data-structures/types/avl-tree.ts rename to src/types/data-structures/avl-tree.ts index 3fd4dc8..45a8892 100644 --- a/src/data-structures/types/avl-tree.ts +++ b/src/types/data-structures/avl-tree.ts @@ -1,4 +1,4 @@ -import {AVLTreeNode} from '../binary-tree'; +import {AVLTreeNode} from '../../data-structures/binary-tree'; import {BSTOptions} from './bst'; export type AVLTreeNodeNested = AVLTreeNode>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/src/data-structures/types/binary-tree.ts b/src/types/data-structures/binary-tree.ts similarity index 95% rename from src/data-structures/types/binary-tree.ts rename to src/types/data-structures/binary-tree.ts index d63afe9..f6e7b91 100644 --- a/src/data-structures/types/binary-tree.ts +++ b/src/types/data-structures/binary-tree.ts @@ -1,4 +1,4 @@ -import {BinaryTreeNode} from '../binary-tree'; +import {BinaryTreeNode} from '../../data-structures/binary-tree'; import {AbstractBinaryTreeOptions} from './abstract-binary-tree'; diff --git a/src/data-structures/types/bst.ts b/src/types/data-structures/bst.ts similarity index 94% rename from src/data-structures/types/bst.ts rename to src/types/data-structures/bst.ts index df3ee8d..d51564c 100644 --- a/src/data-structures/types/bst.ts +++ b/src/types/data-structures/bst.ts @@ -1,4 +1,4 @@ -import {BSTNode} from '../binary-tree'; +import {BSTNode} from '../../data-structures/binary-tree'; import type {BinaryTreeOptions} from './binary-tree'; import {BinaryTreeNodeId} from './abstract-binary-tree'; diff --git a/src/data-structures/types/directed-graph.ts b/src/types/data-structures/directed-graph.ts similarity index 100% rename from src/data-structures/types/directed-graph.ts rename to src/types/data-structures/directed-graph.ts diff --git a/src/data-structures/types/doubly-linked-list.ts b/src/types/data-structures/doubly-linked-list.ts similarity index 100% rename from src/data-structures/types/doubly-linked-list.ts rename to src/types/data-structures/doubly-linked-list.ts diff --git a/src/data-structures/types/heap.ts b/src/types/data-structures/heap.ts similarity index 100% rename from src/data-structures/types/heap.ts rename to src/types/data-structures/heap.ts diff --git a/src/data-structures/types/index.ts b/src/types/data-structures/index.ts similarity index 89% rename from src/data-structures/types/index.ts rename to src/types/data-structures/index.ts index b78574b..165cb6c 100644 --- a/src/data-structures/types/index.ts +++ b/src/types/data-structures/index.ts @@ -12,5 +12,4 @@ export * from './priority-queue'; export * from './heap'; export * from './singly-linked-list'; export * from './doubly-linked-list'; -export * from './navigator'; -export * from './helpers'; \ No newline at end of file +export * from './navigator'; \ No newline at end of file diff --git a/src/data-structures/types/map-graph.ts b/src/types/data-structures/map-graph.ts similarity index 100% rename from src/data-structures/types/map-graph.ts rename to src/types/data-structures/map-graph.ts diff --git a/src/data-structures/types/navigator.ts b/src/types/data-structures/navigator.ts similarity index 100% rename from src/data-structures/types/navigator.ts rename to src/types/data-structures/navigator.ts diff --git a/src/data-structures/types/priority-queue.ts b/src/types/data-structures/priority-queue.ts similarity index 100% rename from src/data-structures/types/priority-queue.ts rename to src/types/data-structures/priority-queue.ts diff --git a/src/data-structures/types/rb-tree.ts b/src/types/data-structures/rb-tree.ts similarity index 93% rename from src/data-structures/types/rb-tree.ts rename to src/types/data-structures/rb-tree.ts index 35a7b91..0cc1a44 100644 --- a/src/data-structures/types/rb-tree.ts +++ b/src/types/data-structures/rb-tree.ts @@ -1,5 +1,5 @@ import {BinaryTreeOptions} from './binary-tree'; -import {RBTreeNode} from '../binary-tree'; +import {RBTreeNode} from '../../data-structures/binary-tree'; export enum RBColor { RED = 'RED', BLACK = 'BLACK'} diff --git a/src/data-structures/types/segment-tree.ts b/src/types/data-structures/segment-tree.ts similarity index 100% rename from src/data-structures/types/segment-tree.ts rename to src/types/data-structures/segment-tree.ts diff --git a/src/data-structures/types/singly-linked-list.ts b/src/types/data-structures/singly-linked-list.ts similarity index 100% rename from src/data-structures/types/singly-linked-list.ts rename to src/types/data-structures/singly-linked-list.ts diff --git a/src/data-structures/types/tree-multiset.ts b/src/types/data-structures/tree-multiset.ts similarity index 94% rename from src/data-structures/types/tree-multiset.ts rename to src/types/data-structures/tree-multiset.ts index 3778140..50761a4 100644 --- a/src/data-structures/types/tree-multiset.ts +++ b/src/types/data-structures/tree-multiset.ts @@ -1,4 +1,4 @@ -import {TreeMultisetNode} from '../binary-tree'; +import {TreeMultisetNode} from '../../data-structures/binary-tree'; import {AVLTreeOptions} from './avl-tree'; export type TreeMultisetNodeNested = TreeMultisetNode>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/src/data-structures/types/helpers.ts b/src/types/helpers.ts similarity index 100% rename from src/data-structures/types/helpers.ts rename to src/types/helpers.ts diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..de67430 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,3 @@ +export * from './data-structures'; +export * from './helpers'; +export * from './utils'; \ No newline at end of file diff --git a/src/utils/types/index.ts b/src/types/utils/index.ts similarity index 100% rename from src/utils/types/index.ts rename to src/types/utils/index.ts diff --git a/src/utils/types/utils.ts b/src/types/utils/utils.ts similarity index 100% rename from src/utils/types/utils.ts rename to src/types/utils/utils.ts diff --git a/src/utils/types/validate-type.ts b/src/types/utils/validate-type.ts similarity index 100% rename from src/utils/types/validate-type.ts rename to src/types/utils/validate-type.ts diff --git a/src/utils/index.ts b/src/utils/index.ts index 7e60a97..4ecd603 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,2 @@ export * from './utils'; -export * from './types'; export * from './validate-type'; \ No newline at end of file diff --git a/src/utils/utils.ts b/src/utils/utils.ts index bf28bff..d1df63c 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from './types'; +import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types'; export const uuidV4 = function () { return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) { diff --git a/src/utils/validate-type.ts b/src/utils/validate-type.ts index ab0b1cb..159aaf3 100644 --- a/src/utils/validate-type.ts +++ b/src/utils/validate-type.ts @@ -1,5 +1,5 @@ import {z} from 'zod'; -import {NonNumberNonObjectButDefined, ObjectWithNonNumberId, ObjectWithNumberId, ObjectWithoutId} from './types'; +import {NonNumberNonObjectButDefined, ObjectWithNonNumberId, ObjectWithNumberId, ObjectWithoutId} from '../types/utils'; export const nonNumberNonObjectButDefinedSchema = z.union([z.string(),