BitVecForeachInRangeIdx

Table of Contents

BitVecForeachInRangeIdx

Description

Iterate over bits in a specific range of the given bitvector bv at each index idx. The variables var and idx are declared and defined by this macro. idx will start from start and will go till end - 1

Parameters

NameDirectionDescription
bvin,outBitvector to iterate over.
varinName of variable to be used which’ll contain bit value at iterated index idx.
idxinName of variable to be used for iterating over indices.
startinStarting index (inclusive).
endinEnding index (exclusive).

Usage example (Cross-references)

    // Test BitVecForeachInRangeIdx macro
    bool test_bitvec_foreach_in_range_idx(void) {
    WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
    
    BitVec bv = BitVecInit();
    bool range_correct = true;
    
    BitVecForeachInRangeIdx(&bv, bit, idx, 1, 4) {
    // Should iterate over indices 1, 2, 3
    // Values: false, true, false
    // Test BitVecForeachInRangeIdx macro
    bool test_bitvec_foreach_in_range_idx(void) {
    WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
    
    BitVec bv = BitVecInit();
    bool range_correct = true;
    
    BitVecForeachInRangeIdx(&bv, bit, idx, 1, 4) {
    // Should iterate over indices 1, 2, 3
    // Values: false, true, false
    /// end[in]      : Ending index (exclusive).
    ///
    #define BitVecForeachInRange(bv, var, start, end) BitVecForeachInRangeIdx((bv), (var), UNPL(iter), (start), (end))
    
    #endif // MISRA_STD_CONTAINER_BITVEC_FOREACH_H

Share :