4 个版本 (2 个破坏性更新)

0.3.2 2021年2月17日
0.3.1 2021年2月4日
0.1.0 2020年11月15日
0.0.2 2020年10月26日

#dynamically-sized 中排名第 13

Download history 34/week @ 2024-03-12 18/week @ 2024-03-19 8/week @ 2024-03-26 40/week @ 2024-04-02 23/week @ 2024-04-09 21/week @ 2024-04-16 35/week @ 2024-04-23 2/week @ 2024-04-30 15/week @ 2024-05-07 18/week @ 2024-05-14 31/week @ 2024-05-21 28/week @ 2024-05-28 31/week @ 2024-06-04 23/week @ 2024-06-11 22/week @ 2024-06-18 26/week @ 2024-06-25

每月下载量 108

MIT 许可证

15KB
235 代码行

动态大小的轻量级位图

说明

简单、快速且易于使用的位图。

示例

use dyn_bitmap::DynBitmap;
use std::io::Write;

let source = [true, false, false].iter()
    .cycle()
    .take(256);

// You can construct bitmap from iterator with `Type = bool` or
// construct bitmap manually with `contained/1`.
//
// `DynBitmap` has high-performance `from_iter` method,
// which is preferable to `contained/1`.
let mut bitmap: DynBitmap = source.copied().collect();

// You can set value of bitmap using `set/2` function.
// It returns additional information in case of an error.
bitmap.set(true, 1).unwrap();
// You can check value of some particular bit using `get/1`.
// Note, that bit index starts from `0`.
assert_eq!(bitmap.get(1).unwrap(), true);

// You can iterate over bit values using `iter/0` function.
for (idx, value) in bitmap.iter().enumerate() {
    println!("{}: {}", idx, value);
}

let file = std::fs::File::open("foo.bin").unwrap();
// `write/1` function support writing binary bitmap representation
// to anything that implement `std::io::Write`.
bitmap.write(file).unwrap();

依赖

~285–750KB
~18K SLoC