Mac Developer Library

Developer

CoreFoundation Framework Reference CFBitVector Reference

Options
Deployment Target:

On This Page
Language:

CFBitVector Reference

CFBitVector and its derived mutable type, CFMutableBitVector, manage ordered collections of bit values, which are either 0 or 1. CFBitVector creates static bit vectors and CFMutableBitVector creates dynamic bit vectors.

Functions

  • Creates an immutable bit vector from a block of memory.

    Declaration

    Swift

    func CFBitVectorCreate(_ allocator: CFAllocator!, _ bytes: UnsafePointer<UInt8>, _ numBits: CFIndex) -> CFBitVector!

    Objective-C

    CFBitVectorRef CFBitVectorCreate ( CFAllocatorRef allocator, const UInt8 *bytes, CFIndex numBits );

    Parameters

    allocator

    The allocator to use to allocate memory for the new bit vector. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    bytes

    A pointer to the bit values to store in the new bit vector. The values are copied into the bit vector’s own memory. The bit indices are numbered left-to-right with 0 being the left-most, or most-significant, bit in the byte stream.

    numBits

    The number of bits in the bit vector.

    Return Value

    A new bit vector. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Creates an immutable bit vector that is a copy of another bit vector.

    Declaration

    Swift

    func CFBitVectorCreateCopy(_ allocator: CFAllocator!, _ bv: CFBitVector!) -> CFBitVector!

    Objective-C

    CFBitVectorRef CFBitVectorCreateCopy ( CFAllocatorRef allocator, CFBitVectorRef bv );

    Parameters

    allocator

    The allocator to use to allocate memory for the new bit vector. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    bv

    The bit vector to copy.

    Return Value

    A new bit vector holding the same bit values as bv. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns whether a bit vector contains a particular bit value.

    Declaration

    Swift

    func CFBitVectorContainsBit(_ bv: CFBitVector!, _ range: CFRange, _ value: CFBit) -> Boolean

    Objective-C

    Boolean CFBitVectorContainsBit ( CFBitVectorRef bv, CFRange range, CFBit value );

    Parameters

    bv

    The bit vector to search.

    range

    The range of bits in bv to search.

    value

    The bit value for which to search.

    Return Value

    true if the specified range of bits in bv contains value, otherwise false.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the bit value at a given index in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetBitAtIndex(_ bv: CFBitVector!, _ idx: CFIndex) -> CFBit

    Objective-C

    CFBit CFBitVectorGetBitAtIndex ( CFBitVectorRef bv, CFIndex idx );

    Parameters

    bv

    The bit vector to examine.

    idx

    The index of the bit value in bv to return.

    Return Value

    The bit value at index idx in bv.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the bit values in a range of indices in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetBits(_ bv: CFBitVector!, _ range: CFRange, _ bytes: UnsafeMutablePointer<UInt8>)

    Objective-C

    void CFBitVectorGetBits ( CFBitVectorRef bv, CFRange range, UInt8 *bytes );

    Parameters

    bv

    The bit vector to examine.

    range

    The range of bit values to return.

    bytes

    On return, contains the requested bit values from bv. This argument must point to enough memory to hold the number of bits requested. The requested bits are left-aligned with the first requested bit stored in the left-most, or most-significant, bit of the byte stream.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the number of bit values in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetCount(_ bv: CFBitVector!) -> CFIndex

    Objective-C

    CFIndex CFBitVectorGetCount ( CFBitVectorRef bv );

    Parameters

    bv

    The bit vector to examine.

    Return Value

    The current size of bv.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Counts the number of times a certain bit value occurs within a range of bits in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetCountOfBit(_ bv: CFBitVector!, _ range: CFRange, _ value: CFBit) -> CFIndex

    Objective-C

    CFIndex CFBitVectorGetCountOfBit ( CFBitVectorRef bv, CFRange range, CFBit value );

    Parameters

    bv

    The bit vector to examine.

    range

    The range of bits in bv to search.

    value

    The bit value to count.

    Return Value

    The number of occurrences of value in the specified range of bv.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Locates the first occurrence of a certain bit value within a range of bits in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetFirstIndexOfBit(_ bv: CFBitVector!, _ range: CFRange, _ value: CFBit) -> CFIndex

    Objective-C

    CFIndex CFBitVectorGetFirstIndexOfBit ( CFBitVectorRef bv, CFRange range, CFBit value );

    Parameters

    bv

    The bit vector to examine.

    range

    The range of bits in bv to search.

    value

    The bit value for which to search.

    Return Value

    The index of the first occurrence of value in the specified range of bv, or kCFNotFound if value is not present.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Locates the last occurrence of a certain bit value within a range of bits in a bit vector.

    Declaration

    Swift

    func CFBitVectorGetLastIndexOfBit(_ bv: CFBitVector!, _ range: CFRange, _ value: CFBit) -> CFIndex

    Objective-C

    CFIndex CFBitVectorGetLastIndexOfBit ( CFBitVectorRef bv, CFRange range, CFBit value );

    Parameters

    bv

    The bit vector to examine.

    range

    The range of bits in bv to search.

    value

    The bit value for which to search.

    Return Value

    The index of the last occurrence of value in the specified range of bv, or kCFNotFound if value is not present.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the type identifier for the CFBitVector opaque type.

    Declaration

    Swift

    func CFBitVectorGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFBitVectorGetTypeID ( void );

    Return Value

    The type identifier for the CFBitVector opaque type.

    Discussion

    CFMutableBitVector objects have the same type identifier as CFBitVector objects.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

Data Types

Miscellaneous

  • A binary value of either 0 or 1.

    Declaration

    Swift

    typealias CFBit = UInt32

    Objective-C

    typedef UInt32 CFBit;

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • A reference to an immutable bit vector object.

    Declaration

    Swift

    typealias CFBitVectorRef = CFBitVector

    Objective-C

    typedef const struct __CFBitVector *CFBitVectorRef;

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.