Skip to content
BitVecAllocator

BitVecAllocator

Description

Allocator backing the bitvector’s storage.

Parameters

Name Direction Description
bv in Bitvector to query.

Usage example (Cross-references)

Usage examples (Cross-references)
                StrIterDataAt(&si, StrIterIndex(&hex_saved)),
                StrIterIndex(&si) - StrIterIndex(&hex_saved),
                BitVecAllocator(bv)
            );
            u64            value;
                bit_len = 4;
    
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&hex_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
                StrIterDataAt(&si, StrIterIndex(&oct_saved)),
                StrIterIndex(&si) - StrIterIndex(&oct_saved),
                BitVecAllocator(bv)
            );
            u64            value;
                bit_len = 3;
    
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&oct_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
            StrIterDataAt(&si, StrIterIndex(&bin_saved)),
            StrIterIndex(&si) - StrIterIndex(&bin_saved),
            BitVecAllocator(bv)
        );
        );
    
        *bv = BitVecFromStr(StrBegin(&bin_str), BitVecAllocator(bv));
    
        StrDeinit(&bin_str);
        // configuration fields on the base allocator.
        bool result = BitVecLen(&clone) == BitVecLen(&original) && BitVecCapacity(&clone) >= BitVecLen(&original) &&
                      BitVecAllocator(&clone) == BitVecAllocator(&original) &&
                      BitVecAllocator(&clone)->allocate == BitVecAllocator(&original)->allocate &&
                      BitVecAllocator(&clone)->remap == BitVecAllocator(&original)->remap &&
        bool result = BitVecLen(&clone) == BitVecLen(&original) && BitVecCapacity(&clone) >= BitVecLen(&original) &&
                      BitVecAllocator(&clone) == BitVecAllocator(&original) &&
                      BitVecAllocator(&clone)->allocate == BitVecAllocator(&original)->allocate &&
                      BitVecAllocator(&clone)->remap == BitVecAllocator(&original)->remap &&
                      BitVecAllocator(&clone)->deallocate == BitVecAllocator(&original)->deallocate &&
                      BitVecAllocator(&clone) == BitVecAllocator(&original) &&
                      BitVecAllocator(&clone)->allocate == BitVecAllocator(&original)->allocate &&
                      BitVecAllocator(&clone)->remap == BitVecAllocator(&original)->remap &&
                      BitVecAllocator(&clone)->deallocate == BitVecAllocator(&original)->deallocate &&
                      BitVecAllocator(&clone)->effort == BitVecAllocator(&original)->effort &&
                      BitVecAllocator(&clone)->allocate == BitVecAllocator(&original)->allocate &&
                      BitVecAllocator(&clone)->remap == BitVecAllocator(&original)->remap &&
                      BitVecAllocator(&clone)->deallocate == BitVecAllocator(&original)->deallocate &&
                      BitVecAllocator(&clone)->effort == BitVecAllocator(&original)->effort &&
                      BitVecAllocator(&clone)->retry_limit == BitVecAllocator(&original)->retry_limit &&
                      BitVecAllocator(&clone)->remap == BitVecAllocator(&original)->remap &&
                      BitVecAllocator(&clone)->deallocate == BitVecAllocator(&original)->deallocate &&
                      BitVecAllocator(&clone)->effort == BitVecAllocator(&original)->effort &&
                      BitVecAllocator(&clone)->retry_limit == BitVecAllocator(&original)->retry_limit &&
                      BitVecGet(&clone, 0) == true && BitVecGet(&clone, 1) == false && BitVecGet(&clone, 2) == true;
                      BitVecAllocator(&clone)->deallocate == BitVecAllocator(&original)->deallocate &&
                      BitVecAllocator(&clone)->effort == BitVecAllocator(&original)->effort &&
                      BitVecAllocator(&clone)->retry_limit == BitVecAllocator(&original)->retry_limit &&
                      BitVecGet(&clone, 0) == true && BitVecGet(&clone, 1) == false && BitVecGet(&clone, 2) == true;
        Str    str;
        bool   ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
        bool   result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&
                      (BitVecAllocator(&bv)->retry_limit == alloc.base.retry_limit);
        bool   ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
        bool   result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&
                      (BitVecAllocator(&bv)->retry_limit == alloc.base.retry_limit);
    
        ok     = BitVecTryToStr(&str, &bv);
    /// TAGS: Int, Access, Allocator
    ///
    #define IntAllocator(value) BitVecAllocator(&(value)->bits)
    
    #ifdef __cplusplus
    ///
    #define BitVecTryToStr(...)              OVERLOAD(BitVecTryToStr, __VA_ARGS__)
    #define BitVecTryToStr_2(out, bv)        bitvec_try_to_str((out), (bv), BitVecAllocator((bv)))
    #define BitVecTryToStr_3(out, bv, alloc) bitvec_try_to_str((out), (bv), (alloc))
    ///
    #define BitVecToStr(...)         OVERLOAD(BitVecToStr, __VA_ARGS__)
    #define BitVecToStr_1(bv)        bitvec_to_str((bv), BitVecAllocator((bv)))
    #define BitVecToStr_2(bv, alloc) bitvec_to_str((bv), (alloc))
Last updated on