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) {
    printf("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

BitVecRemoveFirst

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

Read More

BitVecRemoveRange

BitVecRemoveRange Description Remove multiple consecutive bits starting at a specific position. All bits after the removed range are shifted left.

Read More