From 1a0bb945339749572a46633e7e9e8e8a901fa5b2 Mon Sep 17 00:00:00 2001 From: Eyas Ranjous Date: Wed, 13 Oct 2021 00:24:58 -0500 Subject: [PATCH 1/2] ts types --- src/avlTree.d.ts | 16 ++++++++-------- src/binarySearchTree.d.ts | 16 ++++++++-------- src/binarySearchTreeNode.d.ts | 14 +++++++------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/avlTree.d.ts b/src/avlTree.d.ts index 3bed1cd..8ea719b 100644 --- a/src/avlTree.d.ts +++ b/src/avlTree.d.ts @@ -3,14 +3,14 @@ import { AvlTreeNode } from './avlTreeNode'; export class AvlTree extends BinarySearchTree { insert(key: T, value?: U): AvlTreeNode; - find(key: T): AvlTreeNode; - max(node?: AvlTreeNode): AvlTreeNode; - min(node?: AvlTreeNode): AvlTreeNode; - lowerBound(k: T, includeEqual?: boolean): AvlTreeNode; - floor(k: T, includeEqual?: boolean): AvlTreeNode; - upperBound(k: T, includeEqual?: boolean): AvlTreeNode; - ceil(k: T, includeEqual?: boolean): AvlTreeNode; - root(): AvlTreeNode; + find(key: T): AvlTreeNode | null; + max(node?: AvlTreeNode): AvlTreeNode | null; + min(node?: AvlTreeNode): AvlTreeNode | null; + lowerBound(k: T, includeEqual?: boolean): AvlTreeNode | null; + floor(k: T, includeEqual?: boolean): AvlTreeNode | null; + upperBound(k: T, includeEqual?: boolean): AvlTreeNode | null; + ceil(k: T, includeEqual?: boolean): AvlTreeNode | null; + root(): AvlTreeNode | null; traverseInOrder(cb: (node: AvlTreeNode) => void): void; traversePreOrder(cb: (node: AvlTreeNode) => void): void; traversePostOrder(cb: (node: AvlTreeNode) => void): void; diff --git a/src/binarySearchTree.d.ts b/src/binarySearchTree.d.ts index 9c981b0..4577605 100644 --- a/src/binarySearchTree.d.ts +++ b/src/binarySearchTree.d.ts @@ -3,14 +3,14 @@ import { BinarySearchTreeNode } from './binarySearchTreeNode'; export class BinarySearchTree { insert(key: T, value?: U): BinarySearchTreeNode; has(key: T): boolean; - find(key: T): BinarySearchTreeNode; - max(node?: BinarySearchTreeNode): BinarySearchTreeNode; - min(node?: BinarySearchTreeNode): BinarySearchTreeNode; - lowerBound(k: T, includeEqual?: boolean): BinarySearchTreeNode; - floor(k: T, includeEqual?: boolean): BinarySearchTreeNode; - upperBound(k: T, includeEqual?: boolean): BinarySearchTreeNode; - ceil(k: T, includeEqual?: boolean): BinarySearchTreeNode; - root(): BinarySearchTreeNode; + find(key: T): BinarySearchTreeNode | null; + max(node?: BinarySearchTreeNode): BinarySearchTreeNode | null; + min(node?: BinarySearchTreeNode): BinarySearchTreeNode | null; + lowerBound(k: T, includeEqual?: boolean): BinarySearchTreeNode | null; + floor(k: T, includeEqual?: boolean): BinarySearchTreeNode | null; + upperBound(k: T, includeEqual?: boolean): BinarySearchTreeNode | null; + ceil(k: T, includeEqual?: boolean): BinarySearchTreeNode | null; + root(): BinarySearchTreeNode | null; count(): number; remove(k: T): boolean; traverseInOrder(cb: (node: BinarySearchTreeNode) => void): void; diff --git a/src/binarySearchTreeNode.d.ts b/src/binarySearchTreeNode.d.ts index 5c1878b..5c1afe8 100644 --- a/src/binarySearchTreeNode.d.ts +++ b/src/binarySearchTreeNode.d.ts @@ -1,17 +1,17 @@ export class BinarySearchTreeNode { - constructor(key: T, value: U); + constructor(key: T, value?: U); setKey(key: T): BinarySearchTreeNode; getKey(): T; setValue(value: U): BinarySearchTreeNode; getValue(): U; - setLeft(left: BinarySearchTreeNode): BinarySearchTreeNode; - getLeft(): BinarySearchTreeNode; + setLeft(left?: BinarySearchTreeNode): BinarySearchTreeNode; + getLeft(): BinarySearchTreeNode | null; hasLeft(): boolean; - setRight(right: BinarySearchTreeNode): BinarySearchTreeNode; - getRight(): BinarySearchTreeNode; + setRight(right?: BinarySearchTreeNode): BinarySearchTreeNode; + getRight(): BinarySearchTreeNode | null; hasRight(): boolean; - setParent(right: BinarySearchTreeNode): BinarySearchTreeNode; - getParent(): BinarySearchTreeNode; + setParent(parent?: BinarySearchTreeNode): BinarySearchTreeNode; + getParent(): BinarySearchTreeNode | null; hasParent(): boolean; isRoot(): boolean; isLeaf(): boolean; From 419b8854a9fd1a1553d7e25c71215994b71f7226 Mon Sep 17 00:00:00 2001 From: Eyas Ranjous Date: Wed, 13 Oct 2021 00:26:02 -0500 Subject: [PATCH 2/2] ? --- src/binarySearchTreeNode.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binarySearchTreeNode.d.ts b/src/binarySearchTreeNode.d.ts index 5c1afe8..82e3b34 100644 --- a/src/binarySearchTreeNode.d.ts +++ b/src/binarySearchTreeNode.d.ts @@ -2,7 +2,7 @@ export class BinarySearchTreeNode { constructor(key: T, value?: U); setKey(key: T): BinarySearchTreeNode; getKey(): T; - setValue(value: U): BinarySearchTreeNode; + setValue(value?: U): BinarySearchTreeNode; getValue(): U; setLeft(left?: BinarySearchTreeNode): BinarySearchTreeNode; getLeft(): BinarySearchTreeNode | null;