Skip to content
BitVecRFindPattern

BitVecRFindPattern

Description

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

Parameters

Name Direction Description
bv in Bitvector to search in
pattern in Pattern to search for
start in Position to start reverse search from

Usage example (from documentation)

  u64 index = BitVecRFindPattern(&flags, &pattern, 20);

Success

Index of occurrence, or SIZE_MAX if not found

Failure

Returns SIZE_MAX when start is out of range or no match exists at or before it.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    u64 BitVecRFindPattern(BitVec *bv, BitVec *pattern, u64 start) {
        ValidateBitVec(bv);
        ValidateBitVec(pattern);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        WriteFmt("Testing BitVecRFindPattern basic functionality\n");
    
        BitVec source  = BitVecInit(ALLOCATOR_OF(&alloc));
    
        // Search from index 8 backwards
        u64 pos = BitVecRFindPattern(&source, &pattern, 8);
        result  = result && (pos == 6); // Should find at position 6
    
        // Search from index 5 backwards
        pos    = BitVecRFindPattern(&source, &pattern, 5);
        result = result && (pos == 3); // Should find at position 3
Last updated on