pub struct BitmapKB(/* private fields */);
Expand description
Experimental struct for now, a bitmap containing 8_192 bits. I wouldn’t yet recommend using this struct until it’s more stable!
Implementations§
Source§impl BitmapKB
impl BitmapKB
pub fn capacity() -> usize
pub fn to_array(&self) -> [usize; 128]
pub fn get(&self, index: usize) -> Result<bool, String>
Sourcepub fn set(&mut self, index: usize, value: bool) -> Result<(), String>
pub fn set(&mut self, index: usize, value: bool) -> Result<(), String>
Examples found in repository?
examples/using_bitmap_kb.rs (line 26)
3fn main() {
4 let mut bitmap = BitmapKB::default();
5 let mut array = [0; 128];
6 array[127] = usize::MAX;
7 println!("{}", bitmap);
8
9 bitmap |= array;
10 println!("{}", bitmap);
11
12 bitmap += 1;
13 println!("{}", bitmap);
14
15 bitmap += usize::MAX;
16 println!("{}", bitmap);
17 bitmap += 1;
18 println!("{}", bitmap);
19
20 let mut a = bitmap;
21 a += 1;
22 println!("A: {}", a);
23 println!("Bitmap: {}", bitmap);
24
25 let mut a = BitmapKB::default();
26 a.set(1054, true).unwrap();
27 a.set(1000, true).unwrap();
28 let mut b = BitmapKB::default();
29 b.set(1054, true).unwrap();
30 b.set(1000, true).unwrap();
31 let mut c = BitmapKB::default();
32 c.set(1054, true).unwrap();
33 assert_eq!(a, b);
34 assert_ne!(a, c);
35}
pub fn from_set(index: usize) -> Option<BitmapKB>
pub fn new(value: bool) -> BitmapKB
Trait Implementations§
Source§impl AddAssign<usize> for BitmapKB
impl AddAssign<usize> for BitmapKB
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moreSource§impl BitAndAssign for BitmapKB
impl BitAndAssign for BitmapKB
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&=
operation. Read moreSource§impl BitOrAssign for BitmapKB
impl BitOrAssign for BitmapKB
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|=
operation. Read moreSource§impl BitXorAssign for BitmapKB
impl BitXorAssign for BitmapKB
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moreSource§impl BitmapSize for BitmapKB
impl BitmapSize for BitmapKB
const MAP_LENGTH: usize = 8_192usize
Source§impl Ord for BitmapKB
impl Ord for BitmapKB
Source§impl PartialOrd for BitmapKB
impl PartialOrd for BitmapKB
impl Copy for BitmapKB
impl Eq for BitmapKB
impl StructuralPartialEq for BitmapKB
Auto Trait Implementations§
impl Freeze for BitmapKB
impl RefUnwindSafe for BitmapKB
impl Send for BitmapKB
impl Sync for BitmapKB
impl Unpin for BitmapKB
impl UnwindSafe for BitmapKB
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more