Skip to content

Commit 24523bc

Browse files
committed
* refactored queue
1 parent 09325c0 commit 24523bc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Sources/Queue.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public struct Queue<Element>: CustomStringConvertible, Sequence {
8080
:description: Constructor.
8181
*/
8282
public init() {
83-
list = DoublyLinkedList<Element>()
83+
list = DoublyLinkedList()
8484
}
8585

8686
//
@@ -89,7 +89,7 @@ public struct Queue<Element>: CustomStringConvertible, Sequence {
8989
// the next value in the sequence of nodes.
9090
// :returns: Queue.Generator
9191
//
92-
public func makeIterator() -> Queue.Iterator {
92+
public func makeIterator() -> Iterator {
9393
return list.makeIterator()
9494
}
9595

@@ -118,21 +118,21 @@ public struct Queue<Element>: CustomStringConvertible, Sequence {
118118
mutating public func removeAll() {
119119
list.removeAll()
120120
}
121-
}
122121

123-
public func +<Element>(lhs: Queue<Element>, rhs: Queue<Element>) -> Queue<Element> {
124-
var q = Queue<Element>()
125-
for x in lhs {
126-
q.enqueue(x)
127-
}
128-
for x in rhs {
129-
q.enqueue(x)
130-
}
131-
return q
132-
}
122+
public static func +(lhs: Queue, rhs: Queue) -> Queue<Element> {
123+
var q = Queue<Element>()
124+
for x in lhs {
125+
q.enqueue(x)
126+
}
127+
for x in rhs {
128+
q.enqueue(x)
129+
}
130+
return q
131+
}
133132

134-
public func +=<Element>(lhs: inout Queue<Element>, rhs: Queue<Element>) {
135-
for x in rhs {
136-
lhs.enqueue(x)
137-
}
133+
public static func +=(lhs: inout Queue, rhs: Queue) {
134+
for x in rhs {
135+
lhs.enqueue(x)
136+
}
137+
}
138138
}

0 commit comments

Comments
 (0)