[−][src]Struct dyn_bitmap::DynBitmap
Dynamicaly sized bitmap.
let mut bitmap = dyn_bitmap::DynBitmap::contained(3); bitmap.set(0).unwrap(); bitmap.set(2).unwrap(); assert!(bitmap.get(0).unwrap()); assert!(!bitmap.get(1).unwrap()); assert!(bitmap.get(2).unwrap());
Implementations
impl DynBitmap
[src]
pub fn contained(bits: usize) -> Self
[src]
Create new bitmap that is guaranteed to hold that many bits
.
Example
use dyn_bitmap::DynBitmap; let bimap = DynBitmap::contained(13);
pub const fn bytes_required(bits: usize) -> usize
[src]
Amount of bytes required for bitmap serialization.
Example
use dyn_bitmap::DynBitmap; let bitmap = DynBitmap::contained(10); assert_eq!(bitmap.byte_size(), DynBitmap::bytes_required(10));
pub fn get(&self, bit_index: usize) -> Result<bool, Error>
[src]
Get bit value.
Example
let mut bitmap = dyn_bitmap::DynBitmap::contained(3); bitmap.set(0).unwrap(); assert!(bitmap.get(0).unwrap()); assert!(!bitmap.get(1).unwrap());
pub fn set(&mut self, bit_index: usize) -> Result<(), Error>
[src]
Set bit value as true
.
Example
let mut bitmap = dyn_bitmap::DynBitmap::contained(3); assert!(!bitmap.get(0).unwrap()); bitmap.set(0).unwrap(); assert!(bitmap.get(0).unwrap());
pub fn clear(&mut self, bit_index: usize) -> Result<(), Error>
[src]
Set bit value as false
.
Example
let mut bitmap = dyn_bitmap::DynBitmap::contained(3); bitmap.set(0).unwrap(); assert!(bitmap.get(0).unwrap()); bitmap.clear(0).unwrap(); assert!(!bitmap.get(0).unwrap());
pub fn write<W: Write>(&self, writer: W) -> Result<()>
[src]
Write bitmap by impl std::io::Write
.
Example
let mut bitmap = dyn_bitmap::DynBitmap::contained(8); bitmap.set(0).unwrap(); bitmap.set(2).unwrap(); bitmap.set(4).unwrap(); bitmap.set(6).unwrap(); let mut buffer: Vec<u8> = Default::default(); let mut cursor = std::io::Cursor::new(&mut buffer); bitmap.write(cursor).unwrap(); assert_eq!(&buffer, &0b0101_0101u8.to_le_bytes()); }
pub fn byte_size(&self) -> usize
[src]
Size of bitmap in bytes.
Example
let bitmap = dyn_bitmap::DynBitmap::contained(9); assert_eq!(bitmap.byte_size(), 2);
pub fn bits_capacity(&self) -> usize
[src]
Auto Trait Implementations
impl RefUnwindSafe for DynBitmap
impl Send for DynBitmap
impl Sync for DynBitmap
impl Unpin for DynBitmap
impl UnwindSafe for DynBitmap
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,