Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cd9c844

Browse files
committed
1.1.0
1 parent f367011 commit cd9c844

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p align="center">
33
<!-- <img src="https://i.loli.net/2018/01/05/5a4f153d36a21.png" alt="SortAlgorithm"> -->
44
<br/><a href="https://cocoapods.org/pods/SortAlgorithm">
5-
<img alt="Version" src="https://img.shields.io/badge/version-1.0.1-brightgreen.svg">
5+
<img alt="Version" src="https://img.shields.io/badge/version-1.1.0-brightgreen.svg">
66
<img alt="Author" src="https://img.shields.io/badge/author-Meniny-blue.svg">
77
<img alt="Build Passing" src="https://img.shields.io/badge/build-passing-brightgreen.svg">
88
<img alt="Swift" src="https://img.shields.io/badge/swift-4.0%2B-orange.svg">

‎Sample/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- SortAlgorithm (1.0.1)
2+
- SortAlgorithm (1.1.0)
33

44
DEPENDENCIES:
55
- SortAlgorithm (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: ../
1010

1111
SPEC CHECKSUMS:
12-
SortAlgorithm: 515a48bb6cdacd5dfa779feac208b1ca8b12e4f6
12+
SortAlgorithm: f046b4e2c467c7342bc0da5613251d6a2e94e0f6
1313

1414
PODFILE CHECKSUM: 879c6730e28f493fd8b0c3a05c18fd17e42c43b6
1515

‎Sample/Pods/Local Podspecs/SortAlgorithm.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sample/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sample/Pods/Target Support Files/SortAlgorithm/Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎SortAlgorithm.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SortAlgorithm'
3-
s.version = "1.0.1"
3+
s.version = "1.1.0"
44
s.summary = "Swift array sort algorithm"
55
s.homepage = "https://github.com/Meniny/SortAlgorithm"
66
s.license = { :type => "MIT", :file => "LICENSE" }

‎SortAlgorithm/SortAlgorithm+HeapSort.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public extension Array where Element: Comparable {
8080
}
8181
return heap.items
8282
}
83+
84+
/// Heap Sort, automatically compared by `l < r`
85+
///
86+
/// - Returns: Sorted Array
87+
public func heapSortAutomatically() -> [Element] {
88+
return self.heapSort(by: { (l, r) -> Bool in
89+
return l < r
90+
})
91+
}
8392
}
8493

8594
// MARK: - HeapSort Helper

‎SortAlgorithm/SortAlgorithm.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ public extension Array where Element: Comparable {
9090
}
9191
return items
9292
}
93+
94+
/// Bubble Sort, automatically compared by `l < r`
95+
///
96+
/// - Returns: Sorted Array
97+
public func bubbleSortAutomatically() -> [Element] {
98+
return self.bubbleSort(by: { (l, r) -> Bool in
99+
return l < r
100+
})
101+
}
93102

94103
// MAKR: - 插入排序
95104
/// Insertion Sort
@@ -113,6 +122,15 @@ public extension Array where Element: Comparable {
113122
}
114123
return items
115124
}
125+
126+
/// Insertion Sort, automatically compared by `l < r`
127+
///
128+
/// - Returns: Sorted Array
129+
public func insertionSortAutomatically() -> [Element] {
130+
return self.insertionSort(by: { (l, r) -> Bool in
131+
return l < r
132+
})
133+
}
116134

117135
// MARK: - 归并排序
118136
/// Merge Sort
@@ -151,6 +169,15 @@ public extension Array where Element: Comparable {
151169
return internal_merge(left: left, right: right, by: compare)
152170
}
153171
}
172+
173+
/// Merge Sort, automatically compared by `l < r`
174+
///
175+
/// - Returns: Sorted Array
176+
public func mergeSortAutomatically() -> [Element] {
177+
return self.mergeSort(by: { (l, r) -> Bool in
178+
return l < r
179+
})
180+
}
154181

155182
// MARK: - 快速排序
156183
/// Quick Sort
@@ -191,4 +218,13 @@ public extension Array where Element: Comparable {
191218
internal_quickSort(&items, left: 0, right: items.count-1, by: compare)
192219
return items
193220
}
221+
222+
/// Quick Sort, automatically compared by `l < r`
223+
///
224+
/// - Returns: Sorted Array
225+
public func quickSortAutomatically() -> [Element] {
226+
return self.quickSort(by: { (l, r) -> Bool in
227+
return l < r
228+
})
229+
}
194230
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /