BitVecDisjoint

Table of Contents

BitVecDisjoint

Description

Check if two bitvectors are disjoint (have no common 1-bits).

Parameters

NameDirectionDescription
bv1inFirst bitvector
bv2inSecond bitvector

Usage example (from documentation)

  bool disjoint = BitVecDisjoint(&set1, &set2);

Usage example (Cross-references)

    }
    
    bool BitVecDisjoint(BitVec *bv1, BitVec *bv2) {
    ValidateBitVec(bv1);
    ValidateBitVec(bv2);
    
    bool BitVecOverlaps(BitVec *bv1, BitVec *bv2) {
    return !BitVecDisjoint(bv1, bv2);
    }
    // Test BitVecDisjoint and BitVecIntersects functions
    bool test_bitvec_disjoint_intersects(void) {
    printf("Testing BitVecDisjoint and BitVecIntersects\n");
    
    BitVec bv1 = BitVecInit();
    
    // Should be disjoint and not intersect
    bool result = BitVecDisjoint(&bv1, &bv2);
    result      = result && !BitVecOverlaps(&bv1, &bv2);
    
    // Should not be disjoint and should intersect
    result = result && !BitVecDisjoint(&bv1, &bv2);
    result = result && BitVecOverlaps(&bv1, &bv2);
    BitVecClear(&bv1);
    BitVecClear(&bv2);
    result = result && BitVecDisjoint(&bv1, &bv2);
    result = result && !BitVecOverlaps(&bv1, &bv2);
    // Test with empty sets
    result = result && !BitVecOverlaps(&bv1, &bv2);
    result = result && BitVecDisjoint(&bv1, &bv2);
    
    // Test single bit sets
    // Test set operations on large vectors
    bool overlaps = BitVecOverlaps(&large1, &large2);
    bool disjoint = BitVecDisjoint(&large1, &large2);
    result        = result && (overlaps != disjoint); // Should be opposite

Share :

Related Posts

BitVecReverse

BitVecReverse Description Reverse the order of all bits in bitvector. First bit becomes last, last becomes first, etc.

Read More

BitVecShiftLeft

BitVecShiftLeft Description Shift all bits in bitvector to the left by specified positions. New bits on the right are filled with zeros.

Read More

BitVecNot

BitVecNot Description Perform bitwise NOT operation on a bitvector. Result is stored in the first bitvector.

Read More