Skip to content
BitVecIsSuperset

BitVecIsSuperset

Description

Check if first bitvector is a superset of the second. A bitvector is a superset if it contains all 1-bits from the other.

Parameters

Name Direction Description
bv1 in Potential superset bitvector
bv2 in Potential subset bitvector

Usage example (from documentation)

  bool is_superset = BitVecIsSuperset(&large_set, &small_set);

Success

true if bv1 is a superset of bv2

Failure

false when any 1-bit of bv2 is not also set in bv1.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool BitVecIsSuperset(const BitVec *bv1, const BitVec *bv2) {
        return BitVecIsSubset(bv2, bv1);
    }
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        WriteFmt("Testing BitVecIsSuperset\n");
    
        BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // superset should be a superset of subset
        bool result = BitVecIsSuperset(&superset, &subset);
    
        // Test non-superset case
        BitVecSet(&superset, 2, false); // Change to 1101
        // Now superset (1101) is not a superset of subset (1010)
        result = result && !BitVecIsSuperset(&superset, &subset);
    
        // Test equal sets (should be superset)
        BitVecPush(&superset, false);
    
        result = result && BitVecIsSuperset(&superset, &subset);
    
        // Clean up
    
        result = result && BitVecIsSubset(&subset, &superset);
        result = result && BitVecIsSuperset(&superset, &subset);
    
        // Clean up
Last updated on