Bitwise OR of two bitmaps. Dispatches to SIMD (AVX-512/AVX2/NEON) for large bitmaps.
(&self, other: &Bitmap)
| 63 | /// |
| 64 | /// Dispatches to SIMD (AVX-512/AVX2/NEON) for large bitmaps. |
| 65 | pub fn or(&self, other: &Bitmap) -> Bitmap { |
| 66 | let max_len = self.len.max(other.len); |
| 67 | let max_words = self.bits.len().max(other.bits.len()); |
| 68 | let mut result = Bitmap::new(max_len); |
| 69 | let min_words = self.bits.len().min(other.bits.len()); |
| 70 | let simd = super::bitmap_simd::ops(); |
| 71 | (simd.or_slices)( |
| 72 | &self.bits[..min_words], |
| 73 | &other.bits[..min_words], |
| 74 | &mut result.bits[..min_words], |
| 75 | ); |
| 76 | // Copy remaining words from the longer bitmap. |
| 77 | if self.bits.len() > min_words { |
| 78 | result.bits[min_words..max_words].copy_from_slice(&self.bits[min_words..max_words]); |
| 79 | } else if other.bits.len() > min_words { |
| 80 | result.bits[min_words..max_words].copy_from_slice(&other.bits[min_words..max_words]); |
| 81 | } |
| 82 | result |
| 83 | } |
| 84 | |
| 85 | /// Count of set bits. |
| 86 | pub fn count_ones(&self) -> usize { |