BitArray
public struct BitArray : Sendable
extension BitArray: Equatable
extension BitArray: Hashable
extension BitArray: MutableCollection
extension BitArray: CustomStringConvertible
An array of bit values represented as Booleans, where true indicates that the bit is on.
-
Declaration
Swift
public struct Position : Comparable -
The value of each bit in the map, represented as a contiguous array of words.
Declaration
Swift
private var bits: [UInt] -
The number of bits in the array.
Declaration
Swift
public private(set) var count: Int { get } -
Creates an empty array.
Declaration
Swift
public init() -
Creates a new array containing
countelements with the valueb.Declaration
Swift
public init(repeating b: Bool, count: Int) -
Creates an array copying the given
contents.Declaration
Swift
public init<S>(_ contents: S) where S : Sequence, S.Element == Bool -
trueiffselfis empty.Declaration
Swift
public var isEmpty: Bool { get } -
trueiff all elements inselfarefalse.Declaration
Swift
public var allFalse: Bool { get } -
trueiff all elements inselfaretrue.Declaration
Swift
public var allTrue: Bool { get } -
The number of bits that the array can contain before allocating new storage.
Declaration
Swift
public var capacity: Int { get } -
Reserves enough space to store
nbits inself.Declaration
Swift
public mutating func reserveCapacity(_ n: Int) -
Adds a new element at the end of the array.
Declaration
Swift
public mutating func append(_ bit: Bool) -
Removes and returns the last element in
selfif it isn’t empty; otherwise returnsnil.Declaration
Swift
public mutating func popLast() -> Bool? -
Removes and returns the last element in
self.Requires
selfis not empty.Declaration
Swift
@discardableResult public mutating func removeLast() -> Bool -
Removes all elements from the array, keeping existing storage if
keepingCapacityistrue.Declaration
Swift
public mutating func removeAll(keepingCapacity: Bool = false) -
Returns the bitwise OR of
lhsandrhs.Requires
self.count == other.count.Declaration
Swift
public static func | (lhs: `Self`, rhs: `Self`) -> BitArray -
Writes the bitwise OR of
lhsandrhstolhs.Requires
self.count == other.count.Declaration
Swift
public static func |= (lhs: inout `Self`, rhs: `Self`) -
Returns the bitwise AND of
lhsandrhs.Requires
self.count == other.count.Declaration
Swift
public static func & (lhs: `Self`, rhs: `Self`) -> BitArray -
Writes the bitwise AND of
lhsandrhstolhs.Requires
self.count == other.count.Declaration
Swift
public static func &= (lhs: inout `Self`, rhs: `Self`) -
Returns the bitwise XOR of
lhsandrhs.Requires
self.count == other.count.Declaration
Swift
public static func ^ (lhs: `Self`, rhs: `Self`) -> BitArray -
Writes the bitwise XOR of
lhsandrhstolhs.Requires
self.count == other.count.Declaration
Swift
public static func ^= (lhs: inout `Self`, rhs: `Self`) -
Assigns each bits in
selfto the result ofoperationapplied on those bits and their corresponding bits inother.Requires
self.count == other.count.Declaration
Swift
private mutating func applyBitwise(_ other: `Self`, _ operation: (UInt, UInt) -> UInt) -
Sets the value
bfor the bit at positionp.Requires
pis a valid position inself.Declaration
Swift
private mutating func setValue(_ b: Bool, for p: Position) -
Declaration
Swift
public static func == (l: `Self`, r: `Self`) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Declaration
Swift
public typealias Index = Position -
Declaration
Swift
public typealias Element = Bool -
Declaration
Swift
public var startIndex: Position { get } -
Declaration
Swift
public var endIndex: Position { get } -
-
Declaration
Swift
public subscript(p: Position) -> Bool { get set } -
Returns
startIndexadvanced by the givenoffset.Declaration
Swift
public func index(at offset: Int) -> Position -
Returns the offset of
positionfrom the start ofself.Declaration
Swift
public func offset(of p: Position) -> Int -
Accesses the element at given
offset.Declaration
Swift
public subscript(offset: Int) -> Bool { get set } -
Declaration
Swift
public var description: String { get }
View on GitHub