Skip to content

Commit c4e3f34

Browse files
authored
Merge pull request kodecocodes#230 from sendilkumarn/deque
deque update to swift 3
2 parents 2da215d + c4a4c89 commit c4e3f34

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

Deque/Deque-Optimized.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public struct Deque<T> {
88
private var head: Int
99
private var capacity: Int
1010

11-
public init(capacity: Int = 10) {
11+
public init(_ capacity: Int = 10) {
1212
self.capacity = max(capacity, 1)
1313
array = .init(count: capacity, repeatedValue: nil)
1414
head = capacity
@@ -22,11 +22,11 @@ public struct Deque<T> {
2222
return array.count - head
2323
}
2424

25-
public mutating func enqueue(element: T) {
25+
public mutating func enqueue(_ element: T) {
2626
array.append(element)
2727
}
2828

29-
public mutating func enqueueFront(element: T) {
29+
public mutating func enqueueFront(_ element: T) {
3030
if head == 0 {
3131
capacity *= 2
3232
let emptySpace = [T?](count: capacity, repeatedValue: nil)

Deque/Deque-Simple.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public struct Deque<T> {
1616
return array.count
1717
}
1818

19-
public mutating func enqueue(element: T) {
19+
public mutating func enqueue(_ element: T) {
2020
array.append(element)
2121
}
2222

23-
public mutating func enqueueFront(element: T) {
23+
public mutating func enqueueFront(_ element: T) {
2424
array.insert(element, atIndex: 0)
2525
}
2626

Deque/Deque.playground/Contents.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public struct Deque<T> {
1111
return array.count
1212
}
1313

14-
public mutating func enqueue(element: T) {
14+
public mutating func enqueue(_ element: T) {
1515
array.append(element)
1616
}
1717

18-
public mutating func enqueueFront(element: T) {
19-
array.insert(element, atIndex: 0)
18+
public mutating func enqueueFront(_ element: T) {
19+
array.insert(element, at: 0)
2020
}
2121

2222
public mutating func dequeue() -> T? {

Deque/Deque.playground/timeline.xctimeline

Lines changed: 0 additions & 6 deletions
This file was deleted.

Deque/README.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public struct Deque<T> {
1818
return array.count
1919
}
2020

21-
public mutating func enqueue(element: T) {
21+
public mutating func enqueue(_ element: T) {
2222
array.append(element)
2323
}
2424

25-
public mutating func enqueueFront(element: T) {
25+
public mutating func enqueueFront(_ element: T) {
2626
array.insert(element, atIndex: 0)
2727
}
2828

@@ -120,7 +120,7 @@ public struct Deque<T> {
120120
private var head: Int
121121
private var capacity: Int
122122

123-
public init(capacity: Int = 10) {
123+
public init(_ capacity: Int = 10) {
124124
self.capacity = max(capacity, 1)
125125
array = .init(count: capacity, repeatedValue: nil)
126126
head = capacity
@@ -134,11 +134,11 @@ public struct Deque<T> {
134134
return array.count - head
135135
}
136136

137-
public mutating func enqueue(element: T) {
137+
public mutating func enqueue(_ element: T) {
138138
array.append(element)
139139
}
140140

141-
public mutating func enqueueFront(element: T) {
141+
public mutating func enqueueFront(_ element: T) {
142142
// this is explained below
143143
}
144144

0 commit comments

Comments
 (0)