pub struct BitAlloc16(/* private fields */);
Expand description
A bitmap consisting of only 16 bits. BitAlloc16 acts as the leaf (except the leaf bits of course) nodes in the segment trees.
§Example
use bitmap_allocator::{BitAlloc, BitAlloc16};
let mut ba = BitAlloc16::default();
assert_eq!(BitAlloc16::CAP, 16);
ba.insert(0..16);
for i in 0..16 {
assert!(ba.test(i));
}
ba.remove(2..8);
assert_eq!(ba.alloc(), Some(0));
assert_eq!(ba.alloc(), Some(1));
assert_eq!(ba.alloc(), Some(8));
ba.dealloc(0);
ba.dealloc(1);
ba.dealloc(8);
assert!(!ba.is_empty());
Trait Implementations§
Source§impl BitAlloc for BitAlloc16
impl BitAlloc for BitAlloc16
Source§const CAP: usize = 16usize
const CAP: usize = 16usize
The bitmap has a total of CAP bits, numbered from 0 to CAP-1 inclusively.
Source§fn alloc_contiguous(
&mut self,
base: Option<usize>,
size: usize,
align_log2: usize,
) -> Option<usize>
fn alloc_contiguous( &mut self, base: Option<usize>, size: usize, align_log2: usize, ) -> Option<usize>
Allocate a free block with a given size, and return the first bit position. Read more
Source§fn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool
fn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool
Free a contiguous block of bits. Read more
Source§impl Default for BitAlloc16
impl Default for BitAlloc16
Source§fn default() -> BitAlloc16
fn default() -> BitAlloc16
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BitAlloc16
impl RefUnwindSafe for BitAlloc16
impl Send for BitAlloc16
impl Sync for BitAlloc16
impl Unpin for BitAlloc16
impl UnwindSafe for BitAlloc16
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