BitVecReplaceAll

Table of Contents

BitVecReplaceAll

Description

Replace all occurrences of old pattern with new pattern.

Parameters

NameDirectionDescription
bvinBitvector to modify
old_patterninPattern to find and replace
new_patterninPattern to replace with

Usage example (from documentation)

  u64 count = BitVecReplaceAll(&flags, &old_pat, &new_pat);

Usage example (Cross-references)

    }
    
    u64 BitVecReplaceAll(BitVec *bv, BitVec *old_pattern, BitVec *new_pattern) {
    ValidateBitVec(bv);
    ValidateBitVec(old_pattern);
    // BitVecReplaceAll tests
    bool test_bitvec_replace_all_basic(void) {
    WriteFmt("Testing BitVecReplaceAll basic functionality\n");
    
    BitVec source      = BitVecInit();
    BitVecPush(&new_pattern, true);
    
    u64 replacements = BitVecReplaceAll(&source, &old_pattern, &new_pattern);
    result           = result && (replacements == 3);
    // BitVecReplaceAll tests
    bool test_bitvec_replace_all_basic(void) {
    WriteFmt("Testing BitVecReplaceAll basic functionality\n");
    
    BitVec source      = BitVecInit();
    BitVecPush(&new_pattern, true);
    
    u64 replacements = BitVecReplaceAll(&source, &old_pattern, &new_pattern);
    result           = result && (replacements == 3);

Share :

Related Posts

BitVecFindLastPattern

BitVecFindLastPattern Description Find last occurrence of a bit pattern in the bitvector.

Read More

BitVecFindPattern

BitVecFindPattern Description Find first occurrence of a bit pattern in the bitvector.

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