Skip to content

Commit c7ea3d7

Browse files
authored
Merge pull request #3 from klaaspieter/filter2
Filter fixes
2 parents 2214ebf + 2be0ea4 commit c7ea3d7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Sources/SortedArray.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ extension SortedArray: RandomAccessCollection {
9999
}
100100

101101
public func filter(_ isIncluded: (Element) throws -> Bool) rethrows -> SortedArray<Element> {
102-
return SortedArray(sorted: try filter(isIncluded), areInIncreasingOrder: areInIncreasingOrder)
102+
let newElements: [Element] = try filter(isIncluded)
103+
return SortedArray(sorted: newElements, areInIncreasingOrder: areInIncreasingOrder)
103104
}
104105
}
105106

Tests/SortedArrayTests/SortedArrayTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ extension SortedArrayTests {
183183
("testMin", testMin),
184184
("testMax", testMax),
185185
("testCustomStringConvertible", testCustomStringConvertible),
186-
("testCustomDebugStringConvertible", testCustomDebugStringConvertible)
186+
("testCustomDebugStringConvertible", testCustomDebugStringConvertible),
187+
("testFilter", testFilter),
187188
]
188189
}
189190
}

0 commit comments

Comments
 (0)