Skip to content
BitVecCountPattern

BitVecCountPattern

Description

Count total occurrences of a bit pattern in the bitvector.

Parameters

Name Direction Description
bv in Bitvector to search in
pattern in Pattern to count

Usage example (from documentation)

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

Success

Number of occurrences found

Failure

Returns 0 when the pattern never matches or is longer than bv.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    u64 BitVecCountPattern(BitVec *bv, BitVec *pattern) {
        ValidateBitVec(bv);
        ValidateBitVec(pattern);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        WriteFmt("Testing BitVecCountPattern basic functionality\n");
    
        BitVec source  = BitVecInit(ALLOCATOR_OF(&alloc));
        BitVecPush(&pattern, true);
    
        u64 count = BitVecCountPattern(&source, &pattern);
        result    = result && (count == 4);
        BitVecPush(&pattern, false);
    
        count  = BitVecCountPattern(&source, &pattern);
        result = result && (count == 3);
Last updated on