Crates.io | bitmap-allocator |
lib.rs | bitmap-allocator |
version | 0.2.0 |
source | src |
created_at | 2024-07-18 11:49:44.228802 |
updated_at | 2024-12-10 13:33:08.97055 |
description | Bit allocator based on segment tree algorithm. |
homepage | |
repository | https://github.com/rcore-os/bitmap-allocator |
max_upload_size | |
id | 1307298 |
size | 20,987 |
Bit allocator based on segment tree algorithm.
use bitmap_allocator::{BitAlloc, BitAlloc1M};
let mut ba = BitAlloc1M::default();
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);