Crates.io | bit-matrix |
lib.rs | bit-matrix |
version | 0.8.1 |
source | src |
created_at | 2015-09-07 13:25:45.68963 |
updated_at | 2024-11-17 17:11:29.734846 |
description | Library for bit matrices and vectors. |
homepage | |
repository | https://github.com/pczarn/bit-matrix |
max_upload_size | |
id | 2996 |
size | 38,766 |
Rust library that implements bit matrices. You can check the documentation here.
Built on top of contain-rs/bit-vec.
This simple example calculates the transitive closure of 4x4 bit matrix.
use bit_matrix::BitMatrix;
fn main() {
let mut matrix = BitMatrix::new(4, 4);
let points = &[
(0, 0),
(0, 1),
(0, 3),
(1, 0),
(1, 2),
(2, 0),
(2, 1),
(3, 1),
(3, 3),
];
for &(i, j) in points {
matrix.set(i, j, true);
}
matrix.transitive_closure();
let mut expected_matrix = BitMatrix::new(4, 4);
for i in 0..4 {
for j in 0..4 {
expected_matrix.set(i, j, true);
}
}
assert_eq!(matrix, expected_matrix);
}
Dual-licensed for compatibility with the Rust project.
Licensed under the Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0, or the MIT license: http://opensource.org/licenses/MIT, at your option.