/* commented -- as this doesn't do what it says on the tin.
    it doesn't test for h collision, but node splitting

    #[test]
    fn collision() {
        let k0 = "keyx".to_string();
        let h1 = HashedKey::compute(PhantomData::<DefaultHasher>, &k0);
        let l = h1.level_index(0);
        let mut found = None;
        for i in 0..10000 {
            let x = format!("key{}", i);
            let h2 = HashedKey::compute(PhantomData::<DefaultHasher>, &x);
            if h1 == h2 {
            //if h2.level_index(0) == l {
                found = Some(x.clone());
                break;
            }
        }

        match found {
            None => assert!(false),
            Some(x) => {
                let mut h: Hamt<DefaultHasher, String, u32> = Hamt::new();
                println!("k0: {}", k0);
                h = h.insert(k0.clone(), 1u32).unwrap();
                println!("x: {}", x);
                h = h.insert(x.clone(), 2u32).unwrap();
                assert_eq!(h.size(), 2);
                assert_eq!(h.lookup(&k0), Some(&1u32));
                assert_eq!(h.lookup(&x), Some(&2u32));

                let h2 = h.remove_match(&x, &2u32).unwrap();
                assert_eq!(h2.lookup(&k0), Some(&1u32));
                assert_eq!(h2.size(), 1);

                let h3 = h.remove_match(&k0, &1u32).unwrap();
                assert_eq!(h3.lookup(&x), Some(&2u32));
                assert_eq!(h3.size(), 1);
            }
        }
    }

    fn xproperty_btreemap_eq<A: Eq + Ord + Hash, B: PartialEq>(
        reference: &BTreeMap<A, B>,
        h: &Hamt<A, B>,
    ) -> bool {
        // using the btreemap reference as starting point
        for (k, v) in reference.iter() {
            if h.lookup(k) != Some(v) {
                return false;
            }
        }
        // then asking the hamt for any spurious values
        for (k, v) in h.iter() {
            if reference.get(k) != Some(v) {
                return false;
            }
        }
        true
    }
    */
- as this doesn't do what it says on the tin.
it doesn't test for h collision, but node splitting
- as this doesn ' t do what it says on the tin . it doesn ' t test for h collision but node splitting
fn property_btreemap_eq<A: Eq + Ord + Hash, B: PartialEq>(
        reference: &BTreeMap<A, B>,
        h: &Hamt<A, B>,
    ) -> impl smoke::property::Property {
        let mut same = true;
        // using the btreemap reference as starting point
        for (k, v) in reference.iter() {
            if h.lookup(k) != Some(v) {
                same = false;
            }
        }
        // then asking the hamt for any spurious values
        for (k, v) in h.iter() {
            if reference.get(k) != Some(v) {
                same = false;
            }
        }
        smoke::property::equal(same, true)
    }
fn property_btreemap_eq < A : Eq + Ord + Hash , B : PartialEq > ( reference : & BTreeMap < A , B > , h : & Hamt < A , B > , ) -> impl smoke :: property :: Property { let mut same = true ; // using the btreemap reference as starting point for ( k , v ) in reference . iter ( ) { if h . lookup ( k ) != Some ( v ) { same = false ; } } // then asking the hamt for any spurious values for ( k , v ) in h . iter ( ) { if reference . get ( k ) != Some ( v ) { same = false ; } } smoke :: property :: equal ( same , true ) }
commented -- as this doesn't do what it says on the tin.
commented -- as this doesn ' t do what it says on the tin .
reference
&BTreeMap<A, B>
h
&Hamt<A, B>
[test]
fn collision() {
let k0 = "keyx".to_string();
let h1 = HashedKey::compute(PhantomData::, &k0);
let l = h1.level_index(0);
let mut found = None;
for i in 0..10000 {
let x = format!("key{}", i);
let h2 = HashedKey::compute(PhantomData::, &x);
if h1 == h2 {
if h2.level_index(0) == l {
found = Some(x.clone());
break;
}
}







fn xproperty_btreemap_eq(
reference: &BTreeMap,
h: &Hamt,
) -> bool {
using the btreemap reference as starting point
for (k, v) in reference.iter() {
if h.lookup(k) != Some(v) {
return false;
}
}
then asking the hamt for any spurious values
for (k, v) in h.iter() {
if reference.get(k) != Some(v) {
return false;
}
}
true
}
fn collision () { let k0 = " keyx " . to_string () ; let h1 = HashedKey :: compute ( PhantomData :: &k0 ) ; let l = h1 . level_index ( 0 ) ; let mut found = None ; for i in 0 .. 10000 { let x = format! ( " key {} " i ) ; let h2 = HashedKey :: compute ( PhantomData :: &x ) ; if h1 == h2 { if h2 . level_index ( 0 ) == l { found = Some ( x . clone () ) ; break ; } } fn xproperty_btreemap_eq ( reference : &BTreeMap h : &Hamt ) - > bool { using the btreemap reference as starting point for ( k v ) in reference . iter () { if h . lookup ( k ) ! = Some ( v ) { return false ; } } then asking the hamt for any spurious values for ( k v ) in h . iter () { if reference . get ( k ) ! = Some ( v ) { return false ; } } true }