pub struct RangeSearcher<'a, T: CodeInt> { /* private fields */ }Expand description
Range searcher created by Index::range_searcher().
Implementations§
Source§impl<'a, T> RangeSearcher<'a, T>where
T: CodeInt,
impl<'a, T> RangeSearcher<'a, T>where
T: CodeInt,
Sourcepub fn run(&mut self, qcode: T, radius: usize) -> &[u32]
pub fn run(&mut self, qcode: T, radius: usize) -> &[u32]
Searches neighbor codes whose Hamming distances to a query code are within a query radius.
§Arguments
qcode: Binary code of the query.radius: Threshold to be searched.
§Returns
A slice of ids of codes whose Hamming distances to qcode are within radius.
The ids are sorted.
Note that the values of the slice will be updated in the next RangeSearcher::run().
§Examples
use mih_rs::Index;
let codes: Vec<u64> = vec![
0b1111111111111111111111011111111111111111111111111011101111111111, // #zeros = 3
0b1111111111111111111111111111111101111111111011111111111111111111, // #zeros = 2
0b1111111011011101111111111111111101111111111111111111111111111111, // #zeros = 4
0b1111111111111101111111111111111111111000111111111110001111111110, // #zeros = 8
0b1101111111111111111111111111111111111111111111111111111111111111, // #zeros = 1
0b1111111111111111101111111011111111111111111101001110111111111111, // #zeros = 6
0b1111111111111111111111111111111111101111111111111111011111111111, // #zeros = 2
0b1110110101011011011111111111111101111111111111111000011111111111, // #zeros = 11
];
let index = Index::new(codes).unwrap();
let mut searcher = index.range_searcher();
let qcode: u64 = 0b1111111111111111111111111111111111111111111111111111111111111111; // #zeros = 0
let answers = searcher.run(qcode, 2);
assert_eq!(answers, vec![1, 4, 6]);Auto Trait Implementations§
impl<'a, T> Freeze for RangeSearcher<'a, T>
impl<'a, T> RefUnwindSafe for RangeSearcher<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for RangeSearcher<'a, T>where
T: Sync,
impl<'a, T> Sync for RangeSearcher<'a, T>where
T: Sync,
impl<'a, T> Unpin for RangeSearcher<'a, T>
impl<'a, T> UnwindSafe for RangeSearcher<'a, T>where
T: RefUnwindSafe,
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