diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-07-02 22:03:43 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-07-02 22:05:36 -0400 |
commit | d314f33de39fd3b32d093c2fc2d59c0aeb92c655 (patch) | |
tree | 814ab6da90a8628123cdef442231ee4ed6e81c23 /src | |
parent | 061c1973ad72bf37f72f1a7ca77ee2bc2ae08313 (diff) | |
download | acap-d314f33de39fd3b32d093c2fc2d59c0aeb92c655.tar.xz |
Preallocate the heap for k_nearest*()
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -274,7 +274,7 @@ struct HeapNeighborhood<K, V, D> { } impl<K, V, D: PartialOrd> HeapNeighborhood<K, V, D> { - /// Create a new singleton neighborhood. + /// Create a new HeapNeighborhood. /// /// * `target`: The search target. /// * `k`: The number of nearest neighbors to find. @@ -284,11 +284,11 @@ impl<K, V, D: PartialOrd> HeapNeighborhood<K, V, D> { target, k, threshold, - heap: BinaryHeap::new(), + heap: BinaryHeap::with_capacity(k), } } - /// Convert this result into an optional neighbor. + /// Extract the results from this neighborhood. fn into_vec(self) -> Vec<Neighbor<V, D>> { self.heap .into_sorted_vec() |