File tree Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -83,24 +83,13 @@ public struct SinglyLinkedList<T>
83
83
84
84
// MARK: INITIALIZERS
85
85
86
- /// Creates a list with the given node.
87
- /// NOTE: This method can break value semantics by accepting a node.
88
- ///
89
- /// - Parameter head: First node
90
- internal init ( head: SinglyLinkedListNode < T > )
91
- {
92
- self . storage = IndirectStorage ( )
93
- self . append ( node: head)
94
- }
95
-
96
-
97
86
/// Creates a list with a single element
98
87
///
99
88
/// - Parameter value: element to populate the list with
100
89
public init ( value: T )
101
90
{
102
- let node = SinglyLinkedListNode < T > ( value : value )
103
- self . init ( head : node )
91
+ self . init ( )
92
+ self . append ( value : value )
104
93
}
105
94
106
95
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ class SinglyLinkedListTests: XCTestCase {
47
47
}
48
48
49
49
func testDelete( ) {
50
- var list = SinglyLinkedList < Int > ( head : SinglyLinkedListNode < Int > ( value : 1 ) )
50
+ var list : SinglyLinkedList < Int > = [ 1 ]
51
51
list. append ( value: 2 )
52
52
list. append ( value: 3 )
53
53
list. append ( value: 4 )
@@ -87,7 +87,7 @@ class SinglyLinkedListTests: XCTestCase {
87
87
}
88
88
89
89
func testDeleteDuplicatesInPlace( ) {
90
- var list = SinglyLinkedList < Int > ( head : SinglyLinkedListNode < Int > ( value : 1 ) )
90
+ var list : SinglyLinkedList < Int > = [ 1 ]
91
91
list. append ( value: 2 )
92
92
list. append ( value: 2 )
93
93
list. append ( value: 3 )
You can’t perform that action at this time.
0 commit comments