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

BitVecFindLastPattern

BitVecFindLastPattern Description Find last 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