mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[BitArray] Add docs.
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user