Skip to content

Commit 8f2bf19

Browse files
committed
Change playground as well.
1 parent bd0c74e commit 8f2bf19

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

Bucket Sort/BucketSort.playground/Sources/BucketSort.swift

+5-26
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,6 @@
2020
//
2121
//
2222

23-
import Foundation
24-
// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.
25-
// Consider refactoring the code to use the non-optional operators.
26-
fileprivate func < <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
27-
switch (lhs, rhs) {
28-
case let (l?, r?):
29-
return l < r
30-
case (nil, _?):
31-
return true
32-
default:
33-
return false
34-
}
35-
}
36-
37-
// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.
38-
// Consider refactoring the code to use the non-optional operators.
39-
fileprivate func >= <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
40-
switch (lhs, rhs) {
41-
case let (l?, r?):
42-
return l >= r
43-
default:
44-
return !(lhs < rhs)
45-
}
46-
}
47-
4823
//////////////////////////////////////
4924
// MARK: Main algorithm
5025
//////////////////////////////////////
@@ -87,7 +62,11 @@ private func enoughSpaceInBuckets<T>(_ buckets: [Bucket<T>], elements: [T]) -> B
8762
let maximumValue = elements.max()?.toInt()
8863
let totalCapacity = buckets.count * (buckets.first?.capacity)!
8964

90-
return totalCapacity >= maximumValue
65+
guard let max = maximumValue else {
66+
return false
67+
}
68+
69+
return totalCapacity >= max
9170
}
9271

9372
//////////////////////////////////////
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<playground version='5.0' target-platform='ios'>
2+
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
33
<timeline fileName='timeline.xctimeline'/>
44
</playground>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)