feat(bitmap): Add bit and for AllocBitMap (#793)

This commit is contained in:
LoGin
2024-04-30 18:45:01 +08:00
committed by GitHub
parent 7401bec5e3
commit 7db6e06354
3 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,5 @@
use core::ops::BitAnd;
use alloc::vec::Vec;
use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
@ -108,3 +110,15 @@ impl BitMapOps<usize> for AllocBitmap {
self.core.set_all(self.elements, &mut self.data, value);
}
}
impl BitAnd for AllocBitmap {
type Output = Self;
fn bitand(self, rhs: Self) -> Self::Output {
let mut result = AllocBitmap::new(self.elements);
for i in 0..rhs.data.len() {
result.data[i] = self.data[i] & rhs.data[i];
}
result
}
}