BitVecFuzzyMatch

Table of Contents

BitVecFuzzyMatch

Description

Fuzzy pattern matching allowing up to N mismatches. Useful for approximate pattern matching with error tolerance.

Parameters

NameDirectionDescription
bvinBitvector to search in
patterninPattern to search for
max_errorsinMaximum number of mismatches allowed

Usage example (from documentation)

  u64 index = BitVecFuzzyMatch(&data, &pattern, 2);  // Allow 2 errors

Usage example (Cross-references)

    }
    
    u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors) {
    ValidateBitVec(bv);
    ValidateBitVec(pattern);
    // BitVecFuzzyMatch tests
    bool test_bitvec_fuzzy_match_basic(void) {
    printf("Testing BitVecFuzzyMatch basic functionality\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, true);
    
    u64 pos = BitVecFuzzyMatch(&source, &pattern, 0);
    result  = result && (pos == 6);
    
    // Test with 1 error allowed
    pos    = BitVecFuzzyMatch(&source, &pattern, 1);
    result = result && (pos == 0); // Should match 110 with 1 error
    // BitVecFuzzyMatch tests
    bool test_bitvec_fuzzy_match_basic(void) {
    printf("Testing BitVecFuzzyMatch basic functionality\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, true);
    
    u64 pos = BitVecFuzzyMatch(&source, &pattern, 0);
    result  = result && (pos == 6);
    
    // Test with 1 error allowed
    pos    = BitVecFuzzyMatch(&source, &pattern, 1);
    result = result && (pos == 0); // Should match 110 with 1 error

Share :

Related Posts

BitVecRFindPattern

BitVecRFindPattern Description Search for a pattern starting from a specific position (reverse search).

Read More

BitVecContainsAt

BitVecContainsAt Description Check if bitvector contains the given pattern at a specific position.

Read More

BitVecReplace

BitVecReplace Description Replace first occurrence of old pattern with new pattern.

Read More