bitgrid 0.1.0

A compact, efficient bit grid structure
Documentation
  • Coverage
  • 97.67%
    42 out of 43 items documented5 out of 30 items with examples
  • Size
  • Source code size: 17.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 576.37 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dlamei/bitgrid
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dlamei

bitgrid

A fast, packed bit grid structure for managing N-Dim boolean matrices with:

  • constant-time get/set
  • efficient iteration over set bits,
  • arbitrary word sizes (u8, u16, u32, u64, u128),
  • no_std compatible

Examples

use bitgrid::BitGrid2D;

// Create a 4x4 grid
let mut grid = BitGrid2D::<u32>::new(4, 4);

// Set some bits
grid.set(1, 2);
grid.set(3, 0);

// Check bit states
assert!(grid.get(1, 2));
assert!(!grid.get(0, 0));

// Iterate over set bits
let set_bits: Vec<_> = grid.iter().collect();
assert_eq!(set_bits, vec![[1, 2], [3, 0]]);

For N-Dim grids:

use bitgrid::BitGrid;

// create a 10x10x10x10 grid
let mut space = BitGrid::<u64, 4>::new_n([10, 10, 10, 10]);
space.set_n([1, 2, 3, 4]);
assert!(space.get_n([1, 2, 3, 4]));