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> {
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 )
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ? {
Load Diff This file was deleted.
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments