Skip to main content

Index2DBuilder

Struct Index2DBuilder 

Source
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

Source

pub fn new(count: usize) -> Self

Create a builder for exactly count items with DEFAULT_NODE_SIZE.

Source

pub fn node_size(self, node_size: usize) -> Self

Set the maximum number of children per tree node (clamped to [2, 65535]).

Source

pub fn sort_key(self, key: SortKey2D) -> Self

Choose the sort key (default: SortKey2D::Hilbert).

Source

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.

Source

pub fn parallel_min_items(self, min_items: usize) -> Self

Set the minimum count at which parallel(true) actually enables rayon.

Source

pub fn add(&mut self, item: Box2D)

Add one indexed box.

Source

pub fn finish(self) -> Result<Index2D, BuildError>

Pack the tree and return the finished index.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.