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

BitVecRemove

BitVecRemove Description Remove a bit at given index from bitvector. Shifts all bits after the index to the left.

Read More

BitVecRemoveRange

BitVecRemoveRange Description Remove multiple consecutive bits starting at a specific position. All bits after the removed range are shifted left.

Read More

BitVecRunLengths

BitVecRunLengths Description Analyze run lengths in a bitvector. A run is a sequence of consecutive identical bits. Results array must be pre-allocated with sufficient space.

Read More