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

BitVecDeinit

BitVecDeinit Description Deinitialize bitvector and free all allocated memory. After calling this, the bitvector should not be used unless re-initialized.

Read More

BitVecSwap

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

Read More

BitVecLen

BitVecLen Description Get number of bits currently in bitvector.

Read More