diff options
author | sanine <sanine.not@pm.me> | 2022-05-25 00:32:15 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-05-25 00:32:15 -0500 |
commit | 49b3a5cf1ea2d7ed3f1bf9c1262ee92d66a83a7d (patch) | |
tree | 9ff02afce4a73c01ed43b581c780f5715ee05b7d /modules/KDTree.js | |
parent | 2f2ab5149701243647a5f8d60dc9f771e45b2a5a (diff) |
begin KDTree implementation
Diffstat (limited to 'modules/KDTree.js')
-rw-r--r-- | modules/KDTree.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/KDTree.js b/modules/KDTree.js new file mode 100644 index 0000000..d9133d1 --- /dev/null +++ b/modules/KDTree.js @@ -0,0 +1,33 @@ +'use strict'; + +class NodeType { + static Leaf = new NodeType('Leaf'); + static Branch = new NodeType('Branch'); + + constructor(name) { this.name = name; } + toString() { return `NodeType.${this.name}`; } +} + + +class LeafNode { + constructor(point) { + this.type = NodeType.Leaf; + this.point = point; + } +} +class BranchNode { +} + + +class KDTree { + constructor() { + this.root = null; + } + + insert(point) { + this.root = new LeafNode(point); + } +} + +export { KDTree, NodeType, LeafNode, BranchNode }; +export default KDTree; |