| Crates.io | bitmap-allocator |
| lib.rs | bitmap-allocator |
| version | 0.2.1 |
| created_at | 2024-07-18 11:49:44.228802+00 |
| updated_at | 2025-09-11 15:54:49.42506+00 |
| description | Bit allocator based on segment tree algorithm. |
| homepage | |
| repository | https://github.com/rcore-os/bitmap-allocator |
| max_upload_size | |
| id | 1307298 |
| size | 21,430 |
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);