New function to extend from another bitset.
This commit is contained in:
14
src/lib.rs
14
src/lib.rs
@@ -34,7 +34,7 @@ impl Hasher for BitHasher {
|
|||||||
|
|
||||||
type BitBuildHasher = BuildHasherDefault<BitHasher>;
|
type BitBuildHasher = BuildHasherDefault<BitHasher>;
|
||||||
type BitHashMap<K, V> = HashMap<K, V, BitBuildHasher>;
|
type BitHashMap<K, V> = HashMap<K, V, BitBuildHasher>;
|
||||||
type BitHashSet<T> = HashSet<T, BitBuildHasher>;
|
// type BitHashSet<T> = HashSet<T, BitBuildHasher>;
|
||||||
|
|
||||||
type Block = u64;
|
type Block = u64;
|
||||||
type Storage = BitHashMap<u64, Block>;
|
type Storage = BitHashMap<u64, Block>;
|
||||||
@@ -128,6 +128,18 @@ impl BitSet {
|
|||||||
Some(block) => (block & (1 << bit)) != 0,
|
Some(block) => (block & (1 << bit)) != 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn extend_from_bitset(&mut self, other: &Self) {
|
||||||
|
for (key, value) in &other.blocks {
|
||||||
|
*self.blocks.entry(*key).or_insert(0) |= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.nbits = self.blocks
|
||||||
|
.values()
|
||||||
|
.map(|block| block.count_ones() as usize)
|
||||||
|
.sum();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BitSet {
|
impl Default for BitSet {
|
||||||
|
|||||||
Reference in New Issue
Block a user