Trait cbitmap::bitmap::BitsManage
source · pub trait BitsManage {
Show 15 methods
// Required methods
fn count(&self) -> usize;
fn find_first_one(&self) -> Option<usize>;
fn find_first_zero(&self) -> Option<usize>;
fn get_bool(&self, index: usize) -> bool;
fn set(&mut self, index: usize) -> &mut Self;
fn reset(&mut self, index: usize) -> &mut Self;
fn flip(&mut self, index: usize) -> &mut Self;
fn set_all(&mut self) -> &mut Self;
fn reset_all(&mut self) -> &mut Self;
fn flip_all(&mut self) -> &mut Self;
// Provided methods
fn all(&self) -> bool { ... }
fn any(&self) -> bool { ... }
fn none(&self) -> bool { ... }
fn get_01(&self, index: usize) -> u8 { ... }
fn test(&self, index: usize) -> bool { ... }
}
Expand description
A general trait, structs which implemented this trait provide interfaces to access a range of bits.
Required Methods§
fn count(&self) -> usize
sourcefn find_first_one(&self) -> Option<usize>
fn find_first_one(&self) -> Option<usize>
sourcefn find_first_zero(&self) -> Option<usize>
fn find_first_zero(&self) -> Option<usize>
Provided Methods§
sourcefn all(&self) -> bool
fn all(&self) -> bool
A wrapper of Bitmap::find_first_zero()
.
Return
bool
. true
iff there is no ‘0’ in the
bitmap.
Examples
use cbitmap::bitmap::*;
let mut map = newmap!(0b10;16);
assert_eq!(map.all(), false);
map.set_all();
assert_eq!(map.all(), true);
sourcefn any(&self) -> bool
fn any(&self) -> bool
A wrapper of Bitmap::find_first_one()
.
Return
bool
. true
iff there is ‘1’ in the bitmap.
Examples
use cbitmap::bitmap::*;
let mut map = newmap!(;16);
assert_eq!(map.any(), false);
map.set(10);
assert_eq!(map.any(), true);
sourcefn none(&self) -> bool
fn none(&self) -> bool
A wrapper of Bitmap::find_first_one()
.
Return
bool
. true
iff there is no ‘1’ in
the bitmap.
Examples
use cbitmap::bitmap::*;
let mut map = newmap!(;16);
assert_eq!(map.none(), true);
map.set(10);
assert_eq!(map.none(), false);