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) {
    WriteFmt("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

BitVecToBytes

BitVecToBytes Description Export bitvector to byte array. Copies the internal bit representation to the provided byte array.

Read More

BitVecCompareRange

BitVecCompareRange Description Compare ranges of two bitvectors lexicographically.

Read More

BitVecFromBytes

BitVecFromBytes Description Create bitvector from byte array. Reads the specified number of bits from the byte array.

Read More