Skip to content

Commit

Permalink
Change playground as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacyRicochet committed Oct 5, 2018
1 parent bd0c74e commit 8f2bf19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
31 changes: 5 additions & 26 deletions Bucket Sort/BucketSort.playground/Sources/BucketSort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,6 @@
//
//

import Foundation
// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.
// Consider refactoring the code to use the non-optional operators.
fileprivate func < <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l < r
case (nil, _?):
return true
default:
return false
}
}

// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.
// Consider refactoring the code to use the non-optional operators.
fileprivate func >= <T: Comparable>(lhs: T?, rhs: T?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l >= r
default:
return !(lhs < rhs)
}
}

//////////////////////////////////////
// MARK: Main algorithm
//////////////////////////////////////
Expand Down Expand Up @@ -87,7 +62,11 @@ private func enoughSpaceInBuckets<T>(_ buckets: [Bucket<T>], elements: [T]) -> B
let maximumValue = elements.max()?.toInt()
let totalCapacity = buckets.count * (buckets.first?.capacity)!

return totalCapacity >= maximumValue
guard let max = maximumValue else {
return false
}

return totalCapacity >= max
}

//////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion Bucket Sort/BucketSort.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
<timeline fileName='timeline.xctimeline'/>
</playground>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

0 comments on commit 8f2bf19

Please sign in to comment.