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

BitVecLen

BitVecLen Description Get number of bits currently in bitvector.

Read More

BitVecShrinkToFit

BitVecShrinkToFit Description Reduce bitvector capacity to match its current length. Frees any unused memory allocated beyond the current length.

Read More

BitVecSwap

BitVecSwap Description Efficiently swap the contents of two bitvectors. This is much faster than copying both bitvectors.

Read More