pub struct SimdIndex2DView<'a> { /* private fields */ }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>
impl<'a> SimdIndex2DView<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, LoadError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, LoadError>
Borrow a zero-copy view over the canonical PSINDEX 2D bytes.
Sourcepub fn extent(&self) -> Option<Box2D>
pub fn extent(&self) -> Option<Box2D>
Return the total extent of indexed items, or None for an empty view.
Sourcepub fn search(&self, query: Box2D) -> Vec<usize>
pub fn search(&self, query: Box2D) -> Vec<usize>
Return the indices of all items whose boxes intersect query.
Sourcepub fn search_into(&self, query: Box2D, out: &mut Vec<usize>)
pub fn search_into(&self, query: Box2D, out: &mut Vec<usize>)
Search with a reusable result buffer.
Sourcepub fn search_with<'b>(
&self,
query: Box2D,
workspace: &'b mut SearchWorkspace,
) -> &'b [usize]
pub fn search_with<'b>( &self, query: Box2D, workspace: &'b mut SearchWorkspace, ) -> &'b [usize]
Search with reusable result and traversal buffers.
Sourcepub fn visit<B, F>(&self, query: Box2D, visitor: F) -> ControlFlow<B>
pub fn visit<B, F>(&self, query: Box2D, visitor: F) -> ControlFlow<B>
Visit intersecting items without collecting a result Vec.
Sourcepub fn neighbors(&self, point: Point2D, max_results: usize) -> Vec<usize>
pub fn neighbors(&self, point: Point2D, max_results: usize) -> Vec<usize>
Return up to max_results item indices nearest to point.
Sourcepub fn neighbors_within(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
) -> Vec<usize>
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.
Sourcepub fn neighbors_into(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
results: &mut Vec<usize>,
)
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.
Sourcepub fn neighbors_with<'b>(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
workspace: &'b mut NeighborWorkspace,
) -> &'b [usize]
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.
Sourcepub fn visit_neighbors<B, F>(
&self,
point: Point2D,
max_distance: f64,
visitor: F,
) -> ControlFlow<B>
pub fn visit_neighbors<B, F>( &self, point: Point2D, max_distance: f64, visitor: F, ) -> 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> 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
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>
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>
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