hibitset icon indicating copy to clipboard operation
hibitset copied to clipboard

Add u128 support

Open stevefan1999-personal opened this issue 1 year ago • 3 comments

stevefan1999-personal avatar Oct 14 '24 02:10 stevefan1999-personal

Huh, strange, why is it still not behaving like HashSet<u32>?

use hibitset::GenericBitSet;

fn main() {
    let mut set = GenericBitSet::<u128>::new();
    set.add(u32::MAX);
    println!("{set:?}");
}
thread 'main' panicked at F:\Git\github.com\stevefan1999-personal\hibitset\src\lib.rs:96:13:
Expected index to be less then 268435456, found 4294967295

stevefan1999-personal avatar Oct 14 '24 02:10 stevefan1999-personal

The MAX_EID is:

const MAX_EID: u32 = (2 << (Self::LOG_BITS * LAYERS) - 1) as u32;

so for u128 that is 2 ^ (7 * 4) = 268435456

I haven't looked into how the MAX_EID formula was derived, so can't offer further explanation.

Imberflur avatar Oct 15 '24 16:10 Imberflur

The MAX_EID is:

const MAX_EID: u32 = (2 << (Self::LOG_BITS * LAYERS) - 1) as u32;

so for u128 that is 2 ^ (7 * 4) = 268435456

I haven't looked into how the MAX_EID formula was derived, so can't offer further explanation.

That's a pity since I cannot have more than 2^28 entities in the map, I guess its well enough for non-extreme situations.

stevefan1999-personal avatar Oct 15 '24 16:10 stevefan1999-personal