BitVecRemoveLast

Table of Contents

BitVecRemoveLast

Description

Remove the last occurrence of a specific bit value. Returns true if a bit was found and removed, false otherwise.

Parameters

NameDirectionDescription
bvinBitvector to remove from
valueinBit value to find and remove (true or false)

Usage example (from documentation)

  bool found = BitVecRemoveLast(&flags, false);

Usage example (Cross-references)

    }
    
    bool BitVecRemoveLast(BitVec *bv, bool value) {
    ValidateBitVec(bv);
    // Test BitVecRemoveLast function
    bool test_bitvec_remove_last(void) {
    WriteFmt("Testing BitVecRemoveLast\n");
    
    BitVec bv = BitVecInit();
    
    // 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) && (bv.length == 0);
    
    found  = BitVecRemoveLast(&bv, false);
    result = result && (found == false) && (bv.length == 0);

Share :

Related Posts

BitVecReverse

BitVecReverse Description Reverse the order of all bits in bitvector. First bit becomes last, last becomes first, etc.

Read More

BitVecOr

BitVecOr Description Perform bitwise OR operation between two bitvectors. Result is stored in the first bitvector.

Read More

BitVecRotateRight

BitVecRotateRight Description Rotate all bits in bitvector to the right by specified positions. Bits that fall off the right end wrap around to the left.

Read More