bitmap-allocator

Crates.iobitmap-allocator
lib.rsbitmap-allocator
version0.2.0
sourcesrc
created_at2024-07-18 11:49:44.228802
updated_at2024-12-10 13:33:08.97055
descriptionBit allocator based on segment tree algorithm.
homepage
repositoryhttps://github.com/rcore-os/bitmap-allocator
max_upload_size
id1307298
size20,987
crates-io (github:rcore-os:crates-io)

documentation

README

BitmapAllocator

Crates.io Docs.rs CI

Bit allocator based on segment tree algorithm.

Example

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);
Commit count: 16

cargo fmt