pub struct XorDistance<T: PrimInt + Unsigned> { /* private fields */ }

Implementations

Return up to requested count of closest points to the provided x, ordered from the closest to the n-th closest, where n is the count.

The returned closest points count my be lower than the specified count and equal to all points count only in the case that: count > points.len().

Examples
extern crate xor_distance_exercise;

use xor_distance_exercise::xor_distance::XorDistance;

let xor_distance: XorDistance<u64> = XorDistance::new(vec![
    0, 1, 2, 4, 6, 8, 12, 18, 19, 20, 21, 22, 406, 407, 408, 409, 410, 444, 445,
]);

let x = 200;
let count = 10;

let closest_points = xor_distance.closest(x, count);

Return a Some(x) such that self.closest(x) equals closest_points and return None in case such a x does not exists.

Examples
extern crate xor_distance_exercise;

use xor_distance_exercise::xor_distance::XorDistance;

let xor_distance: XorDistance<u64> = XorDistance::new(vec![
    0, 1, 2, 4, 6, 8, 12, 18, 19, 20, 21, 22, 406, 407, 408, 409, 410, 444, 445,
]);

let x = 200;
let count = 10;

// Get closest points and reversed guess of `x`
let closest_points = xor_distance.closest(x, count);
let x_guess = xor_distance.reverse_closest(&closest_points).unwrap();

// Check that both `x` and `guess_x` produce the same result.
assert_eq!(closest_points, xor_distance.closest(x_guess, count));

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.