BitVecCountPattern

Table of Contents

BitVecCountPattern

Description

Count total occurrences of a bit pattern in the bitvector.

Parameters

NameDirectionDescription
bvinBitvector to search in
patterninPattern to count

Usage example (from documentation)

  u64 count = BitVecCountPattern(&flags, &pattern);

Usage example (Cross-references)

    }
    
    u64 BitVecCountPattern(BitVec *bv, BitVec *pattern) {
    ValidateBitVec(bv);
    ValidateBitVec(pattern);
    // BitVecCountPattern tests
    bool test_bitvec_count_pattern_basic(void) {
    WriteFmt("Testing BitVecCountPattern basic functionality\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, true);
    
    u64 count = BitVecCountPattern(&source, &pattern);
    result    = result && (count == 4);
    BitVecPush(&pattern, false);
    
    count  = BitVecCountPattern(&source, &pattern);
    result = result && (count == 3);
    // BitVecCountPattern tests
    bool test_bitvec_count_pattern_basic(void) {
    WriteFmt("Testing BitVecCountPattern basic functionality\n");
    
    BitVec source  = BitVecInit();
    BitVecPush(&pattern, true);
    
    u64 count = BitVecCountPattern(&source, &pattern);
    result    = result && (count == 4);
    BitVecPush(&pattern, false);
    
    count  = BitVecCountPattern(&source, &pattern);
    result = result && (count == 3);

Share :

Related Posts

BitVecStartsWith

BitVecStartsWith Description Check if bitvector starts with the given bit pattern.

Read More

BitVecFind

BitVecFind Description Find index of first occurrence of a specific bit value.

Read More

BitVecFindLast

BitVecFindLast Description Find index of last occurrence of a specific bit value.

Read More