Returns whether there is at least one `false` value in this buffer. This is more efficient than `len() > count_set_bits()` because it can short-circuit as soon as a `false` value is found, without counting all set bits. Returns `false` for empty buffer.
(&self)
| 658 | /// |
| 659 | /// Returns `false` for empty buffer. |
| 660 | pub fn has_false(&self) -> bool { |
| 661 | let bit_chunks = self.unaligned_bit_chunks(); |
| 662 | // UnalignedBitChunk zeros padding bits; fill them with 1s so |
| 663 | // they don't appear as false values. |
| 664 | let lead_mask = !((1u64 << bit_chunks.lead_padding()) - 1); |
| 665 | let trail_mask = if bit_chunks.trailing_padding() == 0 { |
| 666 | u64::MAX |
| 667 | } else { |
| 668 | (1u64 << (64 - bit_chunks.trailing_padding())) - 1 |
| 669 | }; |
| 670 | let (prefix_fill, suffix_fill) = match (bit_chunks.prefix(), bit_chunks.suffix()) { |
| 671 | (Some(_), Some(_)) => (!lead_mask, !trail_mask), |
| 672 | (Some(_), None) => (!lead_mask | !trail_mask, 0), |
| 673 | (None, Some(_)) => (0, !trail_mask), |
| 674 | (None, None) => (0, 0), |
| 675 | }; |
| 676 | let chunks = bit_chunks.chunks(); |
| 677 | let mut exact = chunks.chunks_exact(Self::CHUNK_FOLD_BLOCK_SIZE); |
| 678 | let found = bit_chunks |
| 679 | .prefix() |
| 680 | .is_some_and(|v| (v | prefix_fill) != u64::MAX) |
| 681 | || exact.any(|block| block.iter().fold(u64::MAX, |acc, &c| acc & c) != u64::MAX); |
| 682 | found |
| 683 | || exact.remainder().iter().any(|&c| c != u64::MAX) |
| 684 | || bit_chunks |
| 685 | .suffix() |
| 686 | .is_some_and(|v| (v | suffix_fill) != u64::MAX) |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | impl Not for &BooleanBuffer { |
nothing calls this directly
no test coverage detected