TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Brian Semiglia.
A library for finding differences in 2-dimensional sets. Not exactly performant and still a work in progress.
Items in set must conform to Granularelatable
.
struct Example {
let value: String
let state: Bool
}
extension Example: Granularelatable {
func equality(_ input: Example) -> GranulatedEquality {
if value == input.value && state != input.state { return
.partial
} else if value == input.value && state == input.state { return
.complete
} else { return
.none
}
}
}
Indexed Shifts
["a", "b", "c"].shifts(["b", "a", "d"])
==
[
Shifted(element: "a", origin: 0, destination: 1),
Shifted(element: "b", origin: 1, destination: 0)
]
Indexed Deletions
["a", "b", "c"].deletions(["b", "a", "d"])
==
[
Indexed(element: "c", index: 2)
]
Indexed Additions
["a", "b", "c"].additions(["b", "a", "d"])
==
[
Indexed(element: "c", index: 2)
]
Indexed Updates
[
Example(value: "a", state: true),
Example(value: "b", state: true)
].updates([
Example(value: "a", state: true),
Example(value: "b", state: false)
])
==
[
Indexed(
element: Example(value: "b", state: false),
index: 1
)
]
Index-Pathed Shifts
[["a", "b"], ["c", "d"]].shifts([["a", "d"], ["c", "b"]])
==
[
PathShifted(
element: "b",
origin: IndexPath(row: 1, section: 0),
destination: IndexPath(row: 1, section: 1)
),
PathShifted(
element: "d",
origin: IndexPath(row: 1, section: 1),
destination: IndexPath(row: 1, section: 0)
)
]
iOS 8.0+,
Swift 3.0
Contrast is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Contrast"
Contrast is available under the MIT license. See the LICENSE file for more info.