BitVecIsSuperset

Table of Contents

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

NameDirectionDescription
bv1inPotential superset bitvector
bv2inPotential subset bitvector

Usage example (from documentation)

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

Usage example (Cross-references)

    }
    
    bool BitVecIsSuperset(BitVec *bv1, BitVec *bv2) {
    return BitVecIsSubset(bv2, bv1);
    }
    // Test BitVecIsSuperset function
    bool test_bitvec_is_superset(void) {
    printf("Testing BitVecIsSuperset\n");
    
    BitVec superset = BitVecInit();
    
    // 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

Share :

Related Posts

BitVecEqualsRange

BitVecEqualsRange Description Compare specific ranges of two bitvectors for equality.

Read More

BitVecRotateRight

BitVecRotateRight Description Rotate all bits in bitvector to the right by specified positions. Bits that fall off the right end wrap around to the left.

Read More

BitVecNot

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

Read More