Skip to main content

SimdIndex2DView

Struct SimdIndex2DView 

Source
pub struct SimdIndex2DView<'a> { /* private fields */ }
Available on crate feature simd only.
Expand description

Zero-copy SIMD view over bytes produced by SimdIndex2D::to_bytes or Index2D::to_bytes.

Like Index2DView it borrows the buffer without allocating owned tree storage, but the traversal uses wide::f64x4 overlap tests, assembling lane vectors from four contiguous box records. Ideal for querying memory-mapped indexes without allocating.

Nearest-neighbor results are returned in nondecreasing distance order. Ties between equal-distance items are not stable across index layouts.

§Example

use packed_spatial_index::{Index2DBuilder, SimdIndex2DView, Box2D};

let mut builder = Index2DBuilder::new(1);
builder.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
let bytes = builder.finish_simd().unwrap().to_bytes();

let view = SimdIndex2DView::from_bytes(&bytes)?;
assert_eq!(view.search(Box2D::new(0.5, 0.5, 0.5, 0.5)), vec![0]);

Implementations§

Source§

impl<'a> SimdIndex2DView<'a>

Source

pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, LoadError>

Borrow a zero-copy view over the canonical PSINDEX 2D bytes.

Source

pub fn num_items(&self) -> usize

Return the number of indexed items.

Source

pub fn node_size(&self) -> usize

Return the packed node size.

Source

pub fn extent(&self) -> Option<Box2D>

Return the total extent of indexed items, or None for an empty view.

Source

pub fn search(&self, query: Box2D) -> Vec<usize>

Return the indices of all items whose boxes intersect query.

Source

pub fn search_into(&self, query: Box2D, out: &mut Vec<usize>)

Search with a reusable result buffer.

Source

pub fn search_with<'b>( &self, query: Box2D, workspace: &'b mut SearchWorkspace, ) -> &'b [usize]

Search with reusable result and traversal buffers.

Source

pub fn any(&self, query: Box2D) -> bool

Return true if at least one item intersects query.

Source

pub fn first(&self, query: Box2D) -> Option<usize>

Return one intersecting item, if any.

Source

pub fn visit<B, F>(&self, query: Box2D, visitor: F) -> ControlFlow<B>
where F: FnMut(usize) -> ControlFlow<B>,

Visit intersecting items without collecting a result Vec.

Source

pub fn neighbors(&self, point: Point2D, max_results: usize) -> Vec<usize>

Return up to max_results item indices nearest to point.

Source

pub fn neighbors_within( &self, point: Point2D, max_results: usize, max_distance: f64, ) -> Vec<usize>

Return up to max_results item indices within max_distance of point.

Source

pub fn neighbors_into( &self, point: Point2D, max_results: usize, max_distance: f64, results: &mut Vec<usize>, )

Nearest-neighbor search with a reusable result buffer.

Source

pub fn neighbors_with<'b>( &self, point: Point2D, max_results: usize, max_distance: f64, workspace: &'b mut NeighborWorkspace, ) -> &'b [usize]

Nearest-neighbor search with reusable result and priority-queue buffers.

Source

pub fn visit_neighbors<B, F>( &self, point: Point2D, max_distance: f64, visitor: F, ) -> ControlFlow<B>
where F: FnMut(usize, f64) -> ControlFlow<B>,

Visit items in nondecreasing squared-distance order from point.

Auto Trait Implementations§

§

impl<'a> Freeze for SimdIndex2DView<'a>

§

impl<'a> RefUnwindSafe for SimdIndex2DView<'a>

§

impl<'a> Send for SimdIndex2DView<'a>

§

impl<'a> Sync for SimdIndex2DView<'a>

§

impl<'a> Unpin for SimdIndex2DView<'a>

§

impl<'a> UnsafeUnpin for SimdIndex2DView<'a>

§

impl<'a> UnwindSafe for SimdIndex2DView<'a>

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.