Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xorz57/kdtree
KDTree written in Scala
https://github.com/xorz57/kdtree
data-structures kd-tree kdtree scala scala-datastructures
Last synced: about 2 months ago
JSON representation
KDTree written in Scala
- Host: GitHub
- URL: https://github.com/xorz57/kdtree
- Owner: xorz57
- Created: 2023-07-13T09:17:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-24T19:58:50.000Z (12 months ago)
- Last Synced: 2024-01-24T20:31:08.739Z (12 months ago)
- Topics: data-structures, kd-tree, kdtree, scala, scala-datastructures
- Language: Scala
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# KDTree
[![Scala CI](https://github.com/xorz57/KDTree/actions/workflows/scala.yml/badge.svg)](https://github.com/xorz57/KDTree/actions/workflows/scala.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xorz57_KDTree&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=xorz57_KDTree)## Example
```scala
object KDTreeSample {
def main(args: Array[String]): Unit = {
val points = Vector(
Vector(2.0, 3.0),
Vector(5.0, 4.0),
Vector(9.0, 6.0),
Vector(4.0, 7.0),
Vector(8.0, 1.0),
Vector(7.0, 2.0)
)val tree = KDTree(points)
val result1 = tree.contains(Vector(2.0, 3.0))
val result2 = tree.range(Vector(3.0, 3.0), Vector(6.0, 8.0))
val result3 = tree.nearest(Vector(5.0, 6.0))
val result4 = tree.knn(Vector(5.0, 6.0), 3)println(s"result1: $result1")
println(s"result2: $result2")
println(s"result3: $result3")
println(s"result4: $result4")
}
}
```## Output
```console
result1: true
result2: Vector(Vector(4.0, 7.0), Vector(5.0, 4.0))
result3: (2.0,Vector(4.0, 7.0))
result4: Vector((2.0,Vector(4.0, 7.0)), (4.0,Vector(5.0, 4.0)), (16.0,Vector(9.0, 6.0)))
```