1pub mod minhash;
3pub mod simhash;
4
5use std::hash::Hash;
6
7use hashbrown::HashSet;
8use rand_xoshiro::rand_core::{RngCore, SeedableRng};
9
10#[inline(always)]
12pub(crate) fn hash_u64(x: u64, seed: u64) -> u64 {
13 rand_xoshiro::SplitMix64::seed_from_u64(x ^ seed).next_u64()
14}
15
16pub fn jaccard_distance<I, T>(lhs: I, rhs: I) -> f64
28where
29 I: IntoIterator<Item = T>,
30 T: Hash + Eq,
31{
32 let a = HashSet::<T>::from_iter(lhs);
33 let b = HashSet::<T>::from_iter(rhs);
34 1. - (a.intersection(&b).count() as f64) / (a.union(&b).count() as f64)
35}