mirror of
https://github.com/andreytkachenko/kdtree-rust.git
synced 2024-11-22 01:16:25 +04:00
Upgrade to 2018
This commit is contained in:
parent
863e23c869
commit
09606936ad
10
Cargo.toml
10
Cargo.toml
@ -7,17 +7,19 @@ keywords = ["tree", "dimension" , "nearest", "search", "neighbor"]
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "Unlicense"
|
license = "Unlicense"
|
||||||
description = "K-dimensional tree implemented in Rust for fast NN querying."
|
description = "K-dimensional tree implemented in Rust for fast NN querying."
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "kdtree"
|
name = "kdtree"
|
||||||
path = "src//lib.rs"
|
path = "src/lib.rs"
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench"
|
name = "bench"
|
||||||
|
path = "src/bench.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "~0.3"
|
quickcheck = "~0.9"
|
||||||
rand = "~0.3.12"
|
rand = "~0.7"
|
||||||
bencher = "~0.1.2"
|
bencher = "~0.1"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#[macro_use] extern crate bencher;
|
#[macro_use]
|
||||||
|
extern crate bencher;
|
||||||
extern crate kdtree;
|
extern crate kdtree;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use ::kdtree::*;
|
use crate::kdtree::KdTreePoint;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Bounds {
|
pub struct Bounds {
|
||||||
@ -91,8 +92,8 @@ impl Bounds {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::Bounds;
|
||||||
use ::kdtree::test_common::*;
|
use crate::kdtree::test_common::Point2WithId;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bounds_test() {
|
fn bounds_test() {
|
||||||
|
@ -311,7 +311,7 @@ impl<T: KdTreePoint> KdTreeNode<T> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ::kdtree::test_common::Point2WithId;
|
use crate::kdtree::test_common::Point2WithId;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use ::kdtree::*;
|
use crate::kdtree::KdTreePoint;
|
||||||
|
|
||||||
enum PointsWereOnSide {
|
enum PointsWereOnSide {
|
||||||
Left,
|
Left,
|
||||||
@ -125,14 +125,9 @@ fn partition_kdtree<T: KdTreePoint>(vec: &mut [T], index_of_splitting_point: usi
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ::kdtree::*;
|
|
||||||
use ::kdtree::test_common::*;
|
|
||||||
|
|
||||||
use ::rand::distributions::{IndependentSample, Range};
|
|
||||||
use ::rand::*;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::partition_kdtree;
|
use crate::kdtree::test_common::{Point1WithId, Point2WithId};
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parition_kdtree_works() {
|
fn parition_kdtree_works() {
|
||||||
@ -166,11 +161,11 @@ mod tests {
|
|||||||
if xs.len() == 0 {
|
if xs.len() == 0 {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let between = Range::new(0, xs.len());
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
for _ in 0 .. 5 {
|
for _ in 0 .. 5 {
|
||||||
let random_splitting_index = between.ind_sample(&mut rng);
|
let random_splitting_index = rng.gen_range(0, xs.len());
|
||||||
|
|
||||||
let mut vec = vec.clone();
|
let mut vec = vec.clone();
|
||||||
|
|
||||||
|
@ -6,3 +6,6 @@ extern crate quickcheck;
|
|||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
pub mod kdtree;
|
pub mod kdtree;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod bench;
|
||||||
|
Loading…
Reference in New Issue
Block a user