-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING(data-structures): docs & private internals
This commit completes documentation for the data_structures module, and makes the internals of `BinarySearchTree` properly private, so that `BinarySearchNode` is not leaked.
- Loading branch information
1 parent
8fc19d9
commit 058ae7f
Showing
9 changed files
with
884 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { BinarySearchNode } from "./_binary_search_node.ts"; | ||
import type { Direction } from "./_red_black_node.ts"; | ||
import type { BinarySearchTree } from "./binary_search_tree.ts"; | ||
|
||
// These are the private methods and properties that are shared between the | ||
// binary search tree and red-black tree implementations. They are not meant | ||
// to be used outside of the data structures module. | ||
export const internals: { | ||
/** Returns the root node of the binary search tree. */ | ||
getRoot<T>(tree: BinarySearchTree<T>): BinarySearchNode<T> | null; | ||
/** Sets the root node of the binary search tree. */ | ||
setRoot<T>( | ||
tree: BinarySearchTree<T>, | ||
node: BinarySearchNode<T> | null, | ||
): void; | ||
getCompare<T>(tree: BinarySearchTree<T>): (a: T, b: T) => number; | ||
setCompare<T>( | ||
tree: BinarySearchTree<T>, | ||
compare: (a: T, b: T) => number, | ||
): void; | ||
findNode<T>( | ||
tree: BinarySearchTree<T>, | ||
value: T, | ||
): BinarySearchNode<T> | null; | ||
rotateNode<T>( | ||
tree: BinarySearchTree<T>, | ||
node: BinarySearchNode<T>, | ||
direction: Direction, | ||
): void; | ||
insertNode<T>( | ||
tree: BinarySearchTree<T>, | ||
Node: typeof BinarySearchNode, | ||
value: T, | ||
): BinarySearchNode<T> | null; | ||
removeNode<T>( | ||
tree: BinarySearchTree<T>, | ||
node: BinarySearchNode<T>, | ||
): BinarySearchNode<T> | null; | ||
} = {} as typeof internals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.