Ranged Bitmap
A high-performance bitmap library with both fixed-size and flexible bitmap implementations.
Features
- All functions are constant
- Optimized range operations that work on multiple bits simultaneously
- Fixed-size bitmaps with compile-time size determination
- Flexible bitmaps that grow dynamically as needed
- No_std compatibility for embedded and bare-metal environments
Performance
This 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 - All functions are marked
#[inline(always)]for aggressive inlining - Constant functions enable compile-time optimizations
- Hardware-accelerated bit counting operations
Basic Usage
Fixed Bitmap (Compile-time size)
use generate_fixed_bit_map_struct;
generate_fixed_bit_map_struct!
Flexible Bitmap (Dynamic size)
use FlexBitMap;
// Create a flexible bitmap that grows as needed
let mut bitmap = new;
// Automatically grows when setting bits beyond current capacity
bitmap.set; // Grows to accommodate bit 1000
bitmap.set_range; // Grows to accommodate the range
// All operations work the same as fixed bitmap
assert!;
assert!;
// Check current capacity
println!;
println!;
Range Operations
The library excels at a range of operations:
use FixedBitMap;
let mut bitmap = new; // 128 bits
// Efficiently set large ranges
bitmap.set_range; // Set first block
bitmap.set_range; // Set second block
// Check range status
assert!;
// Clear ranges efficiently
bitmap.clear_range; // Clear middle portion
Performance Characteristics
| Operation | Complexity | Notes |
|---|---|---|
| Individual bit get/set/clear | O(1) | Single memory access |
| Range operations (single block) | O(1) | Bitmask operations |
| Range operations (multi-block) | O(n) | n = number of affected blocks |
| Full block operations | O(n) | memset-like optimizations |
| Bit counting | O(n) | Hardware-accelerated |
License
This project is licensed under the MIT License.