File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,16 @@ extension LinkedList {
187
187
}
188
188
}
189
189
190
+ extension LinkedList {
191
+ convenience init ( array: Array < T > ) {
192
+ self . init ( )
193
+
194
+ for element in array {
195
+ self . append ( element)
196
+ }
197
+ }
198
+ }
199
+
190
200
let list = LinkedList < String > ( )
191
201
list. isEmpty // true
192
202
list. first // nil
Original file line number Diff line number Diff line change @@ -12,7 +12,9 @@ public class LinkedList<T> {
12
12
public typealias Node = LinkedListNode < T >
13
13
14
14
fileprivate var head : Node ?
15
-
15
+
16
+ public init ( ) { }
17
+
16
18
public var isEmpty : Bool {
17
19
return head == nil
18
20
}
@@ -184,3 +186,13 @@ extension LinkedList {
184
186
return result
185
187
}
186
188
}
189
+
190
+ extension LinkedList {
191
+ convenience init ( array: Array < T > ) {
192
+ self . init ( )
193
+
194
+ for element in array {
195
+ self . append ( element)
196
+ }
197
+ }
198
+ }
You can’t perform that action at this time.
0 commit comments