pub struct Index2DBuilder { /* private fields */ }Expand description
Builder for Index2D and, with the simd feature, SimdIndex2D.
§Example
use packed_spatial_index::{Index2DBuilder, Box2D};
let mut builder = Index2DBuilder::new(2);
builder.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
builder.add(Box2D::new(5.0, 5.0, 6.0, 6.0));
let index = builder.finish().unwrap();
assert_eq!(index.search(Box2D::new(0.0, 0.0, 2.0, 2.0)), vec![0]);Implementations§
Source§impl Index2DBuilder
impl Index2DBuilder
Sourcepub fn new(count: usize) -> Self
pub fn new(count: usize) -> Self
Create a builder for exactly count items with DEFAULT_NODE_SIZE.
Sourcepub fn node_size(self, node_size: usize) -> Self
pub fn node_size(self, node_size: usize) -> Self
Set the maximum number of children per tree node (clamped to [2, 65535]).
Sourcepub fn sort_key(self, key: SortKey2D) -> Self
pub fn sort_key(self, key: SortKey2D) -> Self
Choose the sort key (default: SortKey2D::Hilbert).
Sourcepub fn parallel(self, parallel: bool) -> Self
pub fn parallel(self, parallel: bool) -> Self
Allow adaptive parallel builds through rayon.
Default is false. When set to true, rayon is used only when the item
count is at least the current parallel_min_items threshold.
Sourcepub fn parallel_min_items(self, min_items: usize) -> Self
pub fn parallel_min_items(self, min_items: usize) -> Self
Set the minimum count at which parallel(true)
actually enables rayon.
Sourcepub fn finish(self) -> Result<Index2D, BuildError>
pub fn finish(self) -> Result<Index2D, BuildError>
Pack the tree and return the finished index.
Sourcepub fn finish_simd(self) -> Result<SimdIndex2D, BuildError>
pub fn finish_simd(self) -> Result<SimdIndex2D, BuildError>
Pack the tree into the SIMD-accelerated SoA index.
§Example
use packed_spatial_index::{Index2DBuilder, Box2D};
let mut builder = Index2DBuilder::new(1);
builder.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
let index = builder.finish_simd().unwrap();
assert_eq!(index.search(Box2D::new(0.5, 0.5, 0.5, 0.5)), vec![0]);Auto Trait Implementations§
impl Freeze for Index2DBuilder
impl RefUnwindSafe for Index2DBuilder
impl Send for Index2DBuilder
impl Sync for Index2DBuilder
impl Unpin for Index2DBuilder
impl UnsafeUnpin for Index2DBuilder
impl UnwindSafe for Index2DBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more