BitVecCapacity

Table of Contents

BitVecCapacity

Description

Get capacity of bitvector in bits.

Parameters

NameDirectionDescription
bvinBitvector to get capacity of

Usage example (from documentation)

  u64 max_bits = BitVecCapacity(&flags);

Usage example (Cross-references)

    // Test BitVecLength and BitVecCapacity functions
    bool test_bitvec_length_capacity(void) {
    printf("Testing BitVecLength and BitVecCapacity\n");
    
    BitVec bv = BitVecInit();
    
    result = result && (BitVecLen(&bv) == 3);
    result = result && (BitVecCapacity(&bv) >= 3);
    
    // Reserve more space
    BitVecReserve(&bv, 100);
    result = result && (BitVecLen(&bv) == 3);
    result = result && (BitVecCapacity(&bv) >= 100);
    
    BitVecDeinit(&bv);
    // Test length and capacity macros if they exist
    result = result && (BitVecLen(&bv) == 2);
    result = result && (BitVecCapacity(&bv) >= 2);
    
    // Test some bit operations
    
    // Initially should be empty
    bool result = (BitVecLen(&bv) == 0) && (BitVecCapacity(&bv) == 0);
    
    // Add some bits
    
    result = result && (BitVecLen(&bv) == 3);
    result = result && (BitVecCapacity(&bv) >= 3);
    
    // Test empty check
    // Test all macros on empty bitvector
    result = result && (BitVecLen(&bv) == 0);
    result = result && (BitVecCapacity(&bv) == 0);
    result = result && BitVecEmpty(&bv);
    result = result && (BitVecByteSize(&bv) == 0);
    
    result = result && (BitVecLen(&bv) == 65);
    result = result && (BitVecCapacity(&bv) >= 65);
    result = result && !BitVecEmpty(&bv);
    result = result && (BitVecByteSize(&bv) >= 9); // At least 9 bytes for 65 bits

Share :

Related Posts

BitVecSuffixMatch

BitVecSuffixMatch Description Match bitvector against an array of suffix patterns. Returns the index of the first matching suffix.

Read More

BitVecGet

BitVecGet Description Get the value of bit at given index in bitvector.

Read More

BitVecSet

BitVecSet Description Set the value of bit at given index in bitvector.

Read More