Search::select_simple() doesn't need to take a length

This commit is contained in:
Dirkjan Ochtman 2021-03-04 17:24:55 +01:00
parent 50c4ed60bc
commit c6087de542
1 changed files with 3 additions and 4 deletions

View File

@ -340,7 +340,7 @@ where
}
}
let nearest = search.select_simple(out.len());
let nearest = &search.select_simple()[..out.len()];
for (i, candidate) in nearest.iter().enumerate() {
out[i] = candidate.pid;
}
@ -376,7 +376,7 @@ fn insert<P: Point>(
heuristic: &Option<Heuristic>,
) {
let found = match heuristic {
None => search.select_simple(M * 2),
None => &search.select_simple()[..M * 2],
Some(heuristic) => search.select_heuristic(&points[new], layer, points, *heuristic),
};
@ -653,8 +653,7 @@ impl Search {
}
/// Selection of neighbors for insertion (algorithm 3 from the paper)
fn select_simple(&mut self, num: usize) -> &[Candidate] {
self.nearest.truncate(num);
fn select_simple(&mut self) -> &[Candidate] {
&self.nearest
}
}