Skip to content
BitVecFuzzyMatch

BitVecFuzzyMatch

BitVecFuzzyMatch

Description

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

Parameters

Name Direction Description
bv in Bitvector to search in
pattern in Pattern to search for
max_errors in Maximum number of mismatches allowed

Usage example (from documentation)

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

Returns

Index of first fuzzy match, or SIZE_MAX if not found

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors) {
        ValidateBitVec(bv);
        ValidateBitVec(pattern);
    // BitVecFuzzyMatch tests
    bool test_bitvec_fuzzy_match_basic(void) {
        WriteFmt("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) {
        WriteFmt("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
Last updated on