BitArray

一个在 Swift 中具有 RandomAccessCollection 一致性的空间高效位数组。

用法

创建数组时指定位数

var a = Array(3) // create an array of length 3
a[0] // false
a[1] = true
a[1] // true
let b = Array(a) // `b` has the same content as `a`.

遵循标准库协议

let c: BitArray = [true, false, true]
let d = c.map { !$0 } // [false, true, false]
print(d) // "[false, true, false]"
c == d // false

有关更多信息,请参见源代码。

安装

Swift Package Manager

.package(url: "git@github.com:dduan/BitArray.git", .branch("master")),

(并添加 "BitArray" 到目标依赖项中.)

CocoaPods

use_frameworks!

pod "BitArray"

Carthage

github "dduan/BitArray"

Xcode

以传统方式在您的工作区中包含 BitArray.xcodeproj

嵌入

在您的项目中包含 Sources/BitArray/BitArray.swift

许可证

MIT.