File tree Expand file tree Collapse file tree 5 files changed +13
-19
lines changed Expand file tree Collapse file tree 5 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ public struct Deque<T> {
8
8
private var head : Int
9
9
private var capacity : Int
10
10
11
- public init ( capacity: Int = 10 ) {
11
+ public init ( _ capacity: Int = 10 ) {
12
12
self . capacity = max ( capacity, 1 )
13
13
array = . init( count: capacity, repeatedValue: nil )
14
14
head = capacity
@@ -22,11 +22,11 @@ public struct Deque<T> {
22
22
return array. count - head
23
23
}
24
24
25
- public mutating func enqueue( element: T ) {
25
+ public mutating func enqueue( _ element: T ) {
26
26
array. append ( element)
27
27
}
28
28
29
- public mutating func enqueueFront( element: T ) {
29
+ public mutating func enqueueFront( _ element: T ) {
30
30
if head == 0 {
31
31
capacity *= 2
32
32
let emptySpace = [ T? ] ( count: capacity, repeatedValue: nil )
Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ public struct Deque<T> {
16
16
return array. count
17
17
}
18
18
19
- public mutating func enqueue( element: T ) {
19
+ public mutating func enqueue( _ element: T ) {
20
20
array. append ( element)
21
21
}
22
22
23
- public mutating func enqueueFront( element: T ) {
23
+ public mutating func enqueueFront( _ element: T ) {
24
24
array. insert ( element, atIndex: 0 )
25
25
}
26
26
Original file line number Diff line number Diff line change @@ -11,12 +11,12 @@ public struct Deque<T> {
11
11
return array. count
12
12
}
13
13
14
- public mutating func enqueue( element: T ) {
14
+ public mutating func enqueue( _ element: T ) {
15
15
array. append ( element)
16
16
}
17
17
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 )
20
20
}
21
21
22
22
public mutating func dequeue( ) -> T ? {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ public struct Deque<T> {
18
18
return array.count
19
19
}
20
20
21
- public mutating func enqueue (element : T) {
21
+ public mutating func enqueue (_ element : T) {
22
22
array.append (element)
23
23
}
24
24
25
- public mutating func enqueueFront (element : T) {
25
+ public mutating func enqueueFront (_ element : T) {
26
26
array.insert (element, atIndex : 0 )
27
27
}
28
28
@@ -120,7 +120,7 @@ public struct Deque<T> {
120
120
private var head: Int
121
121
private var capacity: Int
122
122
123
- public init (capacity : Int = 10 ) {
123
+ public init (_ capacity : Int = 10 ) {
124
124
self .capacity = max (capacity, 1 )
125
125
array = .init (count : capacity, repeatedValue : nil )
126
126
head = capacity
@@ -134,11 +134,11 @@ public struct Deque<T> {
134
134
return array.count - head
135
135
}
136
136
137
- public mutating func enqueue (element : T) {
137
+ public mutating func enqueue (_ element : T) {
138
138
array.append (element)
139
139
}
140
140
141
- public mutating func enqueueFront (element : T) {
141
+ public mutating func enqueueFront (_ element : T) {
142
142
// this is explained below
143
143
}
144
144
You can’t perform that action at this time.
0 commit comments