Structures

The following structures are available globally.

  • A type that uses a fixed width, unsigned integer as storage for an array of bits. The number of bits is fixed and by default are set to zero.

    Using fixed width arrays of bits can be used to implement bitfield like data structures.
    As an example, consider an 8-bit value that represents the following data
    
    +---------+---------+-------+-------+
    | b7:4    | b2:3    | b1    | b0    |
    | Value 2 | Value 1 | Flag2 | Flag1 |
    +---------+---------+-------+-------+
    
    struct Data {
        private var bits: BitField8
    
        var flag1: Bool {
            get { bits[0] }
            set { bits[0] = newValue }
    
        var flag2: Bool { bits[1] }
    
        var value1: Int { bits[2...3] }
    
        var value2: Int {
            get { bits[4...7] }
            set { buts[4...7] = newValue }
        }
    }
    
    See more

    Declaration

    Swift

    public struct BitField<T: FixedWidthInteger & UnsignedInteger>: RandomAccessCollection, MutableCollection,
        CustomStringConvertible
  • An allocator that uses an UnsignedInteger to store the allocated entries allowing upto .bitWidth entries to be allocated.

    See more

    Declaration

    Swift

    public struct BitmapAllocator<BitmapType: FixedWidthInteger & UnsignedInteger>:
        BitmapAllocatorProtocol, CustomStringConvertible
  • An allocator that uses 2 UnsignedIntegers to store the allocated entries allowing upto 2x .bitWidth entries to be allocated.

    See more

    Declaration

    Swift

    public struct DoubleBitmapAllocator<BitmapType: FixedWidthInteger & UnsignedInteger>:
        BitmapAllocatorProtocol, CustomStringConvertible
  • Undocumented

    See more

    Declaration

    Swift

    public struct ByteArray<T> where T : FixedWidthInteger, T : UnsignedInteger
    extension ByteArray: Sequence
    extension ByteArray: MutableCollection
    extension ByteArray: BidirectionalCollection
    extension ByteArray: RandomAccessCollection
    extension ByteArray: RangeReplaceableCollection
    extension ByteArray: Equatable
    extension ByteArray: CustomStringConvertible
    extension ByteArray: CustomDebugStringConvertible
  • Undocumented

    See more

    Declaration

    Swift

    public struct ByteArrayIterator<T> : IteratorProtocol where T : FixedWidthInteger, T : UnsignedInteger
  • NumberSet uses a specified unsigned FixedWidthInteger as the storage for a Set containing the numbers 0…bitWidth. eg a UInt8 can contain the numbers 0...7, a UInt64 can store 0...63. The storage uses a bit per number where bit[x] is used to store x. This gives an ordering of the set from lowest to highest. The rawValue property represents the underlying storage and can be easily interpreted.

    rawValue = 0b1001_0001  [0, 4, 7]
    
    See more

    Declaration

    Swift

    public struct NumberSet<T> : SetAlgebra where T : FixedWidthInteger, T : UnsignedInteger
    extension NumberSet: Sequence
    extension NumberSet: CustomStringConvertible
  • An Iterator that return the elements of a NumberSet.

    See more

    Declaration

    Swift

    public struct NumberSetIterator<T> : IteratorProtocol where T : FixedWidthInteger, T : UnsignedInteger