BitVecInsertMultiple
- Function
- August 22, 2025
Table of Contents
BitVecInsertMultiple
BitVecInsertMultiple
Description
Insert all bits from another bitvector at a specific position. All existing bits at and after the position are shifted right.
Parameters
Name | Direction | Description |
---|---|---|
bv | in | Bitvector to insert into |
idx | in | Position to insert at (0-based) |
other | in | Bitvector whose bits to insert |
Usage example (from documentation)
BitVecInsertMultiple(&flags, 2, &other_flags);
Usage example (Cross-references)
- In
BitVec.c:287
:
}
void BitVecInsertMultiple(BitVec *bv, u64 idx, BitVec *other) {
ValidateBitVec(bv);
ValidateBitVec(other);
// Test BitVecInsertMultiple function
bool test_bitvec_insert_multiple(void) {
printf("Testing BitVecInsertMultiple\n");
BitVec bv = BitVecInit();
// Insert multiple bits from source
BitVecInsertMultiple(&bv, 1, &source);
// Check result: true, true, true, true, false
bool test_bitvec_insert_multiple_edge_cases(void) {
printf("Testing BitVecInsertMultiple edge cases\n");
BitVec bv = BitVecInit();
// Test inserting empty bitvec
BitVecInsertMultiple(&bv, 0, &empty);
result = result && (bv.length == 0);
// Test inserting single bit bitvec
BitVecPush(&source, true);
BitVecInsertMultiple(&bv, 0, &source);
result = result && (bv.length == 1) && (BitVecGet(&bv, 0) == true);
BitVecPush(&source, false);
}
BitVecInsertMultiple(&bv, 1, &source);
result = result && (bv.length == 501);
result = result && (BitVecGet(&bv, 1) == false);