BitVecForeachReverseIdx
- Macro
- August 22, 2025
Table of Contents
BitVecForeachReverseIdx
BitVecForeachReverseIdx
Description
Iterate over each bit var
of given bitvector bv
at each index idx
into the bitvector. The variables var
and idx
declared and defined by this macro. idx
will start from bv->length - 1 and will go till 0
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. |
Usage example (Cross-references)
- In
Foreach.h:108
:
/// invalid index access) will result in a fatal log message and program termination.
///
#define BitVecForeachReverse(bv, var, body) BitVecForeachReverseIdx((bv), (var), (____iter___), {body})
///
// Test BitVecForeachReverseIdx macro
bool test_bitvec_foreach_reverse_idx(void) {
printf("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit();
bool first_bit_is_false = false; // Should be last bit when iterating in reverse
BitVecForeachReverseIdx(&bv, bit, idx, {
if (count == 0) {
first_bit_is_false = (bit == false) && (idx == 3);
count3++;
});
BitVecForeachReverseIdx(&bv, bitval, i, {
(void)bitval;
count4++;
// Test BitVecForeachReverseIdx macro
bool test_bitvec_foreach_reverse_idx(void) {
printf("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit();
bool first_bit_is_false = false; // Should be last bit when iterating in reverse
BitVecForeachReverseIdx(&bv, bit, idx, {
if (count == 0) {
first_bit_is_false = (bit == false) && (idx == 3);
count3++;
});
BitVecForeachReverseIdx(&bv, bitval, i, {
(void)bitval;
count4++;