BitVecRemoveFirst
Description
Remove the first 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 = BitVecRemoveFirst(&flags, true);Success
Returns true. The first bit equal to value has been removed; bitvector length shrinks by one; subsequent bits have shifted left by one.
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:492:
}
bool BitVecRemoveFirst(BitVec *bv, bool value) {
ValidateBitVec(bv);- In
Remove.c:148:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecRemoveFirst\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:160:
// Remove first occurrence of false
bool found = BitVecRemoveFirst(&bv, false);
// Check result: true, true, false, true (removed first false at index 1)
- In
Remove.c:171:
// Try to remove first occurrence of a value that doesn't exist (after removal)
// Actually, false still exists at index 2, so let's remove all falses first
BitVecRemoveFirst(&bv, false); // Remove the remaining false
// Now try to remove false from a bitvector with only trues
- In
Remove.c:174:
// Now try to remove false from a bitvector with only trues
found = BitVecRemoveFirst(&bv, false);
result = result && (found == false) && (BitVecLen(&bv) == 3);- In
Remove.c:361:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecRemoveFirst/Last edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));- In
Remove.c:367:
// Test remove from empty bitvec
bool found = BitVecRemoveFirst(&bv, true);
result = result && (found == false) && (BitVecLen(&bv) == 0);- In
Remove.c:376:
BitVecPush(&bv, true);
BitVecPush(&bv, true);
found = BitVecRemoveFirst(&bv, false);
result = result && (found == false) && (BitVecLen(&bv) == 2);- In
Remove.c:382:
BitVecClear(&bv);
BitVecPush(&bv, false);
found = BitVecRemoveFirst(&bv, false);
result = result && (found == true) && (BitVecLen(&bv) == 0);- In
Remove.c:389:
BitVecPush(&bv, true);
}
found = BitVecRemoveFirst(&bv, true);
result = result && (found == true) && (BitVecLen(&bv) == 999);- In
Remove.c:640:
// 465:5 remove_void_call -- BitVecRemoveFirst must validate its bitvec argument.
bool test_remove_first_null_aborts(void) {
WriteFmt("Testing BitVecRemoveFirst NULL validation\n");
BitVecRemoveFirst(NULL, true);- In
Remove.c:642:
WriteFmt("Testing BitVecRemoveFirst NULL validation\n");
BitVecRemoveFirst(NULL, true);
// If we reach here, validation did not abort.
Last updated on