Expand description
This crate provides the Bitmap
type as a convenient and
efficient way of declaring and working with fixed size bitmaps in Rust.
Examples
let mut bitmap: Bitmap<10> = Bitmap::new();
assert_eq!(bitmap.set(5, true), false);
assert_eq!(bitmap.set(5, true), true);
assert_eq!(bitmap.get(5), true);
assert_eq!(bitmap.get(6), false);
assert_eq!(bitmap.len(), 1);
assert_eq!(bitmap.set(3, true), false);
assert_eq!(bitmap.len(), 2);
assert_eq!(bitmap.first_index(), Some(3));
X86 Arch Support
On x86
and x86_64
architectures, Bitmap
s of size 256, 512,
768 and 1024 gain the load_m256i()
method, which reads the
bitmap into an __m256i
or an array of __m256i
using
_mm256_loadu_si256()
. Bitmap
s of size 128 as
well as the previous gain the load_m128i()
method, which
does the same for __m128i
.
In addition, Bitmap<U128>
and Bitmap<U256>
will have
From
and Into
implementations for __m128i
and
__m256i
respectively.
Note that alignment is unaffected - your bitmaps will be aligned
appropriately for u128
, not __m128i
or __m256i
,
unless you arrange for it to be otherwise. This may affect the performance
of SIMD instructions.