Skip to content

Commit

Permalink
Merge pull request ra1028#8 from ra1028/v0.4.1
Browse files Browse the repository at this point in the history
v0.4.1
  • Loading branch information
ra1028 committed Aug 20, 2018
2 parents e9c1e9a + 4fd99b9 commit b36d4c7
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DifferenceKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DifferenceKit'
spec.version = '0.4.0'
spec.version = '0.4.1'
spec.author = { 'ra1028' => '[email protected]' }
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ The algorithm is optimized based on the Paul Heckel's algorithm.
</H4>

<p align="center">
<a href="https://developer.apple.com/swift"><img alt="Swift4" src="https://img.shields.io/badge/language-swift4-orange.svg?style=flat"/></a>
<a href="https://developer.apple.com/swift"><img alt="Swift4" src="https://img.shields.io/badge/language-Swift4-orange.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/ra1028/DifferenceKit.svg"/></a>
<a href="https://cocoapods.org/pods/DifferenceKit"><img alt="CocoaPods" src="https://img.shields.io/cocoapods/v/DifferenceKit.svg"/></a>
<a href="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/Carthage/Carthage"><img alt="Carthage" src="https://img.shields.io/badge/Carthage-compatible-yellow.svg?style=flat"/></a>
<a href="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/Carthage/Carthage"><img alt="Carthage" src="https://img.shields.io/badge/Carthage-compatible-yellow.svg"/></a>
</br>
<a href="https://travis-ci.org/ra1028/DifferenceKit"><img alt="Build Status" src="https://travis-ci.org/ra1028/DifferenceKit.svg?branch=master"/></a>
<a href="https://developer.apple.com/swift/"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS-green.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/blob/master/LICENSE"><img alt="Lincense" src="http:https://img.shields.io/badge/license-MIT-000000.svg?style=flat"/></a>
<a href="https://developer.apple.com/"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS-green.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/blob/master/LICENSE"><img alt="Lincense" src="http:https://img.shields.io/badge/license-MIT-000000.svg"/></a>
</p>

---
Expand Down
12 changes: 12 additions & 0 deletions Sources/Algorithm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
)
}

// Set the target to `data` of the last stage.
if !changesets.isEmpty {
let index = changesets.index(before: changesets.endIndex)
changesets[index].data = target
}

self.init(changesets)
}
}
Expand Down Expand Up @@ -363,6 +369,12 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
)
}

// Set the target to `data` of the last stage.
if !changesets.isEmpty {
let index = changesets.index(before: changesets.endIndex)
changesets[index].data = target
}

self.init(changesets)
}
}
Expand Down
23 changes: 23 additions & 0 deletions Tests/AlgorithmTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ final class AlgorithmTestCase: XCTestCase {}

/// Test algorithm for linear collection.
extension AlgorithmTestCase {
func testEmptyChangesets() {
let source = [Int]()
let target = [Int]()

XCTAssertExactDifferences(
source: source,
target: target,
section: 0,
expected: []
)
}

func testDeleted() {
let section = 1

Expand Down Expand Up @@ -227,6 +239,17 @@ extension AlgorithmTestCase {

/// Test algorithm for sectioned collection.
extension AlgorithmTestCase {
func testSectionedEmptyChangesets() {
let source = [Section<Int, Int>]()
let target = [Section<Int, Int>]()

XCTAssertExactDifferences(
source: source,
target: target,
expected: []
)
}

func testSectionInserted() {
let source1 = [
Section(model: D.a, elements: [0])
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UICollectionView.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UITableView.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/Differentiable.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/DifferentiableSection.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/AnyDifferentiable.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/Changeset.html
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/ElementPath.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/Section.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/StagedChangeset.html
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
11 changes: 6 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ <H4 align="center">
</H4>

<p align="center">
<a href="https://developer.apple.com/swift"><img alt="Swift4" src="https://img.shields.io/badge/language-swift4-orange.svg?style=flat"/></a>
<a href="https://developer.apple.com/swift"><img alt="Swift4" src="https://img.shields.io/badge/language-Swift4-orange.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/ra1028/DifferenceKit.svg"/></a>
<a href="https://cocoapods.org/pods/DifferenceKit"><img alt="CocoaPods" src="https://img.shields.io/cocoapods/v/DifferenceKit.svg"/></a>
<a href="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/Carthage/Carthage"><img alt="Carthage" src="https://img.shields.io/badge/Carthage-compatible-yellow.svg?style=flat"/></a>
<a href="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/Carthage/Carthage"><img alt="Carthage" src="https://img.shields.io/badge/Carthage-compatible-yellow.svg"/></a>
</br>
<a href="https://travis-ci.org/ra1028/DifferenceKit"><img alt="Build Status" src="https://travis-ci.org/ra1028/DifferenceKit.svg?branch=master"/></a>
<a href="https://developer.apple.com/swift/"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS-green.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/blob/master/LICENSE"><img alt="Lincense" src="http:https://img.shields.io/badge/license-MIT-000000.svg?style=flat"/></a>
<a href="https://developer.apple.com/"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS-green.svg"/></a>
<a href="https://github.com/ra1028/DifferenceKit/blob/master/LICENSE"><img alt="Lincense" src="http:https://img.shields.io/badge/license-MIT-000000.svg"/></a>
</p>

<hr>
Expand Down Expand Up @@ -632,7 +633,7 @@ <h2 id='license' class='heading'>License</h2>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-13)</p>
<p>&copy; 2018 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-08-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy 鈾櫕 v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down

0 comments on commit b36d4c7

Please sign in to comment.