mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 18:26:32 +00:00
feat(bitmap): Add bit and for AllocBitMap (#793)
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user