BitVecRemoveLast
Description
Remove the last occurrence of a specific bit value.
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in,out | Bitvector to remove from. |
value |
in | Bit value to find and remove (true or false). |
Usage example (from documentation)
bool found = BitVecRemoveLast(&flags, false);Success
Returns true. The last bit equal to value has been removed; bitvector length shrinks by one; bits after the removed position have shifted left by one (if any).
Failure
Returns false when no bit equal to value was found. The bitvector is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:476:
}
bool BitVecRemoveLast(BitVec *bv, bool value) {
ValidateBitVec(bv); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecRemoveLast\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Remove last occurrence of false
bool found = BitVecRemoveLast(&bv, false);
// Check result: true, false, true, true (removed last false at index 3)
// Remove last occurrence of true
found = BitVecRemoveLast(&bv, true);
// Check result: true, false, true (removed last true at index 3)
result = result && (found == false) && (BitVecLen(&bv) == 0);
found = BitVecRemoveLast(&bv, false);
result = result && (found == false) && (BitVecLen(&bv) == 0);
Last updated on