@@ -12,7 +12,7 @@ public class BoundedPriorityQueue<T: Comparable> {
12
12
private typealias Node = LinkedListNode < T >
13
13
14
14
private( set) public var count = 0
15
- private var head : Node ?
15
+ fileprivate var head : Node ?
16
16
private var tail : Node ?
17
17
private var maxElements : Int
18
18
@@ -28,7 +28,7 @@ public class BoundedPriorityQueue<T: Comparable> {
28
28
return head? . value
29
29
}
30
30
31
- public func enqueue( value: T ) {
31
+ public func enqueue( _ value: T ) {
32
32
if let node = insert ( value, after: findInsertionPoint ( value) ) {
33
33
// If the newly inserted node is the last one in the list, then update
34
34
// the tail pointer.
@@ -44,7 +44,7 @@ public class BoundedPriorityQueue<T: Comparable> {
44
44
}
45
45
}
46
46
47
- private func insert( value: T , after: Node ? ) -> Node ? {
47
+ private func insert( _ value: T , after: Node ? ) -> Node ? {
48
48
if let previous = after {
49
49
50
50
// 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> {
78
78
79
79
/* Find the node after which to insert the new value. If this returns nil,
80
80
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 ? {
82
82
var node = head
83
83
var prev : Node ? = nil
84
84
85
- while let current = node where value < current. value {
85
+ while let current = node, value < current. value {
86
86
prev = node
87
87
node = current. next
88
88
}
0 commit comments