BitVecSuffixMatch

Table of Contents

BitVecSuffixMatch

Description

Match bitvector against an array of suffix patterns. Returns the index of the first matching suffix.

Parameters

NameDirectionDescription
bvinBitvector to check
patternsinVec(BitVec) to check suffices against

Usage example (from documentation)

  BitVec suffixes[3] = { pattern1, pattern2, pattern3 };
  u64 match = BitVecSuffixMatch(&data, suffixes, 3);

Usage example (Cross-references)

    }
    
    u64 BitVecSuffixMatch(BitVec *bv, BitVecs *patterns) {
    ValidateBitVec(bv);
    if (!patterns) {
    // BitVecSuffixMatch tests
    bool test_bitvec_suffix_match_basic(void) {
    WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
    
    BitVec source = BitVecInit();
    BitVecPush(&patterns[2], false);
    
    u64 match_idx = BitVecSuffixMatch(&source, patterns, 3);
    result        = result && (match_idx == 1);
    
    bool test_bitvec_suffix_match_null_source(void) {
    WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
    BitVec patterns[1] = {BitVecInit()};
    BitVecPush(&patterns[0], true);
    BitVec patterns[1] = {BitVecInit()};
    BitVecPush(&patterns[0], true);
    BitVecSuffixMatch(NULL, patterns, 1);
    BitVecDeinit(&patterns[0]);
    return true;
    
    bool test_bitvec_suffix_match_null_patterns(void) {
    WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecSuffixMatch(&source, NULL, 1);
    BitVecDeinit(&source);
    return true;
    
    bool test_bitvec_suffix_match_null_source(void) {
    WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
    BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit);
    BitVecPush(VecPtrAt(&vp, 0), true);
    BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit);
    BitVecPush(VecPtrAt(&vp, 0), true);
    BitVecSuffixMatch(NULL, &vp);
    VecDeinit(&vp);
    return true;
    
    bool test_bitvec_suffix_match_null_patterns(void) {
    WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVec source = BitVecInit();
    BitVecPush(&source, true);
    BitVecSuffixMatch(&source, NULL);
    BitVecDeinit(&source);
    return true;
    // BitVecSuffixMatch tests
    bool test_bitvec_suffix_match_basic(void) {
    WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
    
    BitVec  source   = BitVecInit();
    BitVecPush(p2, false);
    
    u64 match_idx = BitVecSuffixMatch(&source, &patterns);
    result        = result && (match_idx == 1);

Share :

Related Posts

BitVecFindAllPattern

BitVecFindAllPattern Description Find all occurrences of a bit pattern in the bitvector. Results array must be pre-allocated with sufficient space.

Read More

BitVecRFindPattern

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

Read More

BitVecCountPattern

BitVecCountPattern Description Count total occurrences of a bit pattern in the bitvector.

Read More