Skip to content

Commit 6f14d9e

Browse files
Kelvin LauKelvin Lau
authored andcommitted
Revised playground code to compile in Swift3.
1 parent 35cca84 commit 6f14d9e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Bounded Priority Queue/BoundedPriorityQueue.playground/Sources/BoundedPriorityQueue.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class BoundedPriorityQueue<T: Comparable> {
1212
private typealias Node = LinkedListNode<T>
1313

1414
private(set) public var count = 0
15-
private var head: Node?
15+
fileprivate var head: Node?
1616
private var tail: Node?
1717
private var maxElements: Int
1818

@@ -28,7 +28,7 @@ public class BoundedPriorityQueue<T: Comparable> {
2828
return head?.value
2929
}
3030

31-
public func enqueue(value: T) {
31+
public func enqueue(_ value: T) {
3232
if let node = insert(value, after: findInsertionPoint(value)) {
3333
// If the newly inserted node is the last one in the list, then update
3434
// the tail pointer.
@@ -44,7 +44,7 @@ public class BoundedPriorityQueue<T: Comparable> {
4444
}
4545
}
4646

47-
private func insert(value: T, after: Node?) -> Node? {
47+
private func insert(_ value: T, after: Node?) -> Node? {
4848
if let previous = after {
4949

5050
// If the queue is full and we have to insert at the end of the list,
@@ -78,11 +78,11 @@ public class BoundedPriorityQueue<T: Comparable> {
7878

7979
/* Find the node after which to insert the new value. If this returns nil,
8080
the new value should be inserted at the head of the list. */
81-
private func findInsertionPoint(value: T) -> Node? {
81+
private func findInsertionPoint(_ value: T) -> Node? {
8282
var node = head
8383
var prev: Node? = nil
8484

85-
while let current = node where value < current.value {
85+
while let current = node, value < current.value {
8686
prev = node
8787
node = current.next
8888
}

0 commit comments

Comments
 (0)