[BitArray] Add docs.

This commit is contained in:
Karoy Lorentey committed 2022-08-25 23:50:35 -07:00
1 parent fcac09d86a
commit 5bc22eaf9b
9 files changed
+348 -12

No files matched your search

@@ -10,11 +10,17 @@
//===----------------------------------------------------------------------===//
extension BitArray {
/// Initialize a bit array from a bit set.
///
/// - Complexity: O(1)
public init(_ set: BitSet) {
guard let l = set.last else { self.init(); return }
self.init(_storage: set._storage, count: l + 1)
}
/// Initialize a bit array from the binary representation of an integer.
///
/// - Complexity: O(value.bitWidth)
public init<I: BinaryInteger>(bitPattern value: I) {
let words = value.words.map { _Word($0) }
let count = value.bitWidth