BitVecOverlaps
- Function
- August 22, 2025
Table of Contents
BitVecOverlaps
BitVecOverlaps
Description
Check if two bitvectors overlap (have any common 1-bits).
Parameters
Name | Direction | Description |
---|---|---|
bv1 | in | First bitvector |
bv2 | in | Second bitvector |
Usage example (from documentation)
bool overlaps = BitVecOverlaps(&set1, &set2);
Usage example (Cross-references)
- In
BitVec.c:696
:
}
bool BitVecOverlaps(BitVec *bv1, BitVec *bv2) {
return !BitVecDisjoint(bv1, bv2);
}
// Test BitVecOverlaps function
bool test_bitvec_overlaps(void) {
printf("Testing BitVecOverlaps\n");
BitVec bv1 = BitVecInit();
// They overlap at position 0 (both have 1)
bool result = BitVecOverlaps(&bv1, &bv2);
// Test non-overlapping bitvectors
// They should not overlap (no position where both have 1)
result = result && !BitVecOverlaps(&bv1, &bv2);
// Clean up
// Should be disjoint and not intersect
bool result = BitVecDisjoint(&bv1, &bv2);
result = result && !BitVecOverlaps(&bv1, &bv2);
// Create intersecting bitvectors
// Should not be disjoint and should intersect
result = result && !BitVecDisjoint(&bv1, &bv2);
result = result && BitVecOverlaps(&bv1, &bv2);
// Test with empty bitvectors
BitVecClear(&bv2);
result = result && BitVecDisjoint(&bv1, &bv2);
result = result && !BitVecOverlaps(&bv1, &bv2);
// Clean up
// Test with empty sets
result = result && !BitVecOverlaps(&bv1, &bv2);
result = result && BitVecDisjoint(&bv1, &bv2);
BitVecPush(&bv1, true);
BitVecPush(&bv2, false);
result = result && !BitVecOverlaps(&bv1, &bv2);
// Test large sets
}
// Should have some overlap since both contain position 0 (true)
result = result && BitVecOverlaps(&bv1, &bv2);
BitVecDeinit(&bv1);
// Test set operations on large vectors
bool overlaps = BitVecOverlaps(&large1, &large2);
bool disjoint = BitVecDisjoint(&large1, &large2);
result = result && (overlaps != disjoint); // Should be opposite