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
| Name | Direction | Description |
|---|---|---|
bv |
in,out | Bitvector to iterate over. |
var |
in | Name of variable to be used which’ll contain bit value at iterated index idx. |
idx |
in | Name of variable to be used for iterating over indices. |
start |
in | Starting index (inclusive). |
end |
in | Ending index (exclusive). |
Success
Loop body runs once for each idx in [start, end) that is within bv->length.
Failure
Loop body never executes when the range is empty, inverted, or out of bounds; validator aborts on corrupted magic.
Usage example (Cross-references)
Usage examples (Cross-references)
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); bool range_correct = true;
BitVecForeachInRangeIdx(&bv, bit, idx, 1, 4) {
// Should iterate over indices 1, 2, 3
// Values: false, true, false
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); bool range_correct = true;
BitVecForeachInRangeIdx(&bv, bit, idx, 1, 4) {
// Should iterate over indices 1, 2, 3
// Values: false, true, false
- In
Foreach.h:131:
/// TAGS: BitVec, Foreach, Range, Iteration
///
#define BitVecForeachInRange(bv, var, start, end) BitVecForeachInRangeIdx((bv), (var), UNPL(iter), (start), (end))
#endif // MISRA_STD_CONTAINER_BITVEC_FOREACH_H
Last updated on