diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..60d2378
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,15 @@
+language: swift
+os: osx
+xcode_project: SwiftBitset
+xcode_scheme: SwiftBitset-Package
+osx_image:
+- xcode9.4
+- xcode10
+before_install:
+- brew update
+script:
+- swift package generate-xcodeproj
+- set -o pipefail && xcodebuild -scheme SwiftBitset-Package -enableCodeCoverage YES clean build test
+- swift build
+- swift test
+- swift test -Xswiftc -Ounchecked -s BitsetTests.BitsetTests/testForEachPerformance
diff --git a/Package.swift b/Package.swift
index d27a3d7..eb74667 100644
--- a/Package.swift
+++ b/Package.swift
@@ -7,8 +7,15 @@ let package = Package(
.library(name: "Bitset", targets: ["Bitset"]),
.library(name: "BitsetDynamic", type: .dynamic , targets: ["Bitset"]),
],
+ dependencies: [],
targets: [
- .target(name: "Bitset", dependencies: []),
- .testTarget(name: "BitsetTests", dependencies: ["Bitset"])
+ .target(
+ name: "Bitset",
+ dependencies: []
+ ),
+ .testTarget(
+ name: "BitsetTests",
+ dependencies:["Bitset"]
+ )
]
)
diff --git a/README.md b/README.md
index 6fa13be..0124022 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-
+[![Build Status](https://travis-ci.org/lemire/SwiftBitset.svg?branch=master)](https://travis-ci.org/lemire/SwiftBitset)
A bitset class in Swift for fast and concise set operations over integers. Works under both Linux and MacOS.
It is engineered to be really fast, on par with portable C/C++ implementations.
@@ -14,7 +14,7 @@ $ git clone https://github.com/lemire/SwiftBitsetBenchmark.git
$ cd SwiftBitsetBenchmark
$ swift build -Xcc -march=native --configuration release
-$(swift build --configuration release --show-bin-path)/SwiftBitsetBenchmark
+$ $(swift build --configuration release --show-bin-path)/SwiftBitsetBenchmark
testAddPerformance 10.693318 ms
testIndexSetAddPerformance 231.737616 ms
@@ -101,11 +101,11 @@ for i in b1 {
b1.remove(4) // can remove values
let d1 = b1 & b2;// intersection
let d2 = b1 | b2;// union
-let d3 = b1 &^ b2;// difference
+let d3 = b1 - b2;// difference
let d4 = b1 ^ b2;// symmetric difference
b1 &= b2;// inplace intersection
b1 |= b2;// inplace union
-b1 &^= b2;// inplace difference
+b1 -= b2;// inplace difference
b1 ^= b2;// inplace symmetric difference
```
@@ -143,7 +143,7 @@ $ swift -I .build/release -L .build/release -lBitsetDynamic
```bash
$ swift package generate-xcodeproj
generated: ./Bitset.xcodeproj
-$ open ./Bitset.xcodeproj
+$ open ./SwiftBitset.xcodeproj
```
## Licensing
diff --git a/Sources/Bitset/Bitset.swift b/Sources/Bitset/Bitset.swift
index bffd4d6..e9710c3 100644
--- a/Sources/Bitset/Bitset.swift
+++ b/Sources/Bitset/Bitset.swift
@@ -1,6 +1,4 @@
-infix operator &^;// andNot
-infix operator &^=;// andNot
private extension Int64 {
func toUInt64() -> UInt64 { return UInt64(bitPattern:self) }
@@ -83,15 +81,16 @@ public final class Bitset: Sequence, Equatable, CustomStringConvertible,
lhs.union(rhs)
}
+
// difference between two bitsets, producing a new bitset
- public static func &^ (lhs: Bitset, rhs: Bitset) -> Bitset {
+ public static func - (lhs: Bitset, rhs: Bitset) -> Bitset {
let mycopy = Bitset(lhs)
mycopy.difference(rhs)
return mycopy
}
// inplace difference between two bitsets
- public static func &^= (lhs: Bitset, rhs: Bitset) {
+ public static func -= (lhs: Bitset, rhs: Bitset) {
lhs.difference(rhs)
}
diff --git a/Tests/BitsetTests/BitsetTests.swift b/Tests/BitsetTests/BitsetTests.swift
index 1e04b1d..f1618c1 100644
--- a/Tests/BitsetTests/BitsetTests.swift
+++ b/Tests/BitsetTests/BitsetTests.swift
@@ -193,7 +193,7 @@ class BitsetTests: XCTestCase {
let B1 = Bitset(b1)
let B2 = Bitset(b2)
- b2 &^= b1
+ b2 -= b1
B2.difference(B1)
XCTAssertEqual(B2, b2, "Bad operator")
}
@@ -203,7 +203,7 @@ class BitsetTests: XCTestCase {
let B1 = Bitset(b1)
let B2 = Bitset(b2)
- let b3 = b2 &^ b1
+ let b3 = b2 - b1
B2.difference(B1)
XCTAssertEqual(B2, b3, "Bad operator")
}
@@ -239,11 +239,11 @@ class BitsetTests: XCTestCase {
// will print 1 4 10 1000 10000
_ = b1 & b2;// intersection
_ = b1 | b2;// union
- _ = b1 &^ b2;// difference
+ _ = b1 - b2;// difference
_ = b1 ^ b2;// symmetric difference
b1 &= b2;// inplace intersection
b1 |= b2;// inplace union
- b1 &^= b2;// inplace difference
+ b1 -= b2;// inplace difference
b1 ^= b2;// inplace symmetric difference
}
@@ -271,7 +271,7 @@ class BitsetTests: XCTestCase {
#if os(Linux)
extension BitsetTests {
- static var allTests: [(String, (BitsetTests) -> Void throws->Void)] {
+ static var allTests: [(String, (BitsetTests) -> () throws->())] {
return [
("testUnion", testUnion),
("testIterator", testIterator),