对比 0.1.2

对比 0.1.2

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布时间最后发布2017年11月
SwiftSwift版本3.0
SPM支持SPM

Brian Semiglia 维护。



对比 0.1.2

  • Brian Semiglia

对比

用于在二维集中查找差异的库。尚不完全高效,仍在开发中。

用法

集合中的项必须遵守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
    }
  }
}

示例

索引偏移

["a", "b", "c"].shifts(["b", "a", "d"]) 
==
[
  Shifted(element: "a", origin: 0, destination: 1),
  Shifted(element: "b", origin: 1, destination: 0)
]

索引删除

["a", "b", "c"].deletions(["b", "a", "d"]) 
== 
[
  Indexed(element: "c", index: 2)
]

索引添加

["a", "b", "c"].additions(["b", "a", "d"]) 
==
[
  Indexed(element: "c", index: 2)
]

索引更新

[
  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
  )
]

索引路径偏移

[["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通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中:

pod "Contrast"

许可协议

Contrast是在MIT许可下提供的。有关更多信息,请参阅LICENSE文件。