Expand description
§Ranged Bitmap
A high-performance bitmap library.
This library provides efficient bitmap manipulation with a focus on:
- All functions are constant
- Optimized range operations that work on multiple bits simultaneously
No_stdcompatibility for embedded and bare-metal environments
§Features
- Fixed-size bitmaps with compile-time size determination
- Efficient range setting, clearing, and checking operations
- All functions are constant
§Performance
The library is designed with performance as a primary goal:
- Range operations use precomputed lookup tables for optimal bit manipulation
- Bulk operations on full blocks use
memset-like operations for maximum speed
§Example
use ranged_bitmap::generate_fixed_bit_map_struct;
generate_fixed_bit_map_struct!(struct BitMap<256>); // Generates a 256-bit bitmap struct wrapper
// Create a 256-bit bitmap
let mut bitmap = BitMap::new();
// Set individual bits
bitmap.set(10);
bitmap.set(20);
// Gets individual bits
assert!(bitmap.get(10));
assert!(!bitmap.get(21));
// Set an entire range at once (much faster than individual operations)
bitmap.set_range(50, 100); // Set bits 50-149
bitmap.clear_range(0, 50); // Clear bits 0-49
// Check if a range is completely set or unset
assert!(bitmap.check_range_is_set(50, 100));
assert!(bitmap.check_range_is_unset(0, 50));
// Iterate over a range
for (index, value) in bitmap.iter_range(40, 20) {
println!("Bit {}: {}", index, value);
}
// Count set bits
println!("Total set bits: {}", bitmap.count_ones());
println!("Total unset bits: {}", bitmap.count_zeros());Re-exports§
pub use base::blocks_number_for_bits;
Modules§
- base
- Base module containing core bitmap operations and utilities.
Macros§
- generate_
fixed_ bit_ map_ struct - Generate a typed bitmap wrapper struct.
Structs§
- Fixed
BitMap - A fixed-size bitmap with range operations.