We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8165c59 commit a6b440fCopy full SHA for a6b440f
1 file changed
Sources/SortedArray.swift
@@ -98,6 +98,8 @@ extension SortedArray: RandomAccessCollection {
98
return _elements[position]
99
}
100
101
+ /// Like `Sequence.filter(_:)`, but returns a `SortedArray` instead of an `Array`.
102
+ /// We can do this efficiently because filtering doesn't change the sort order.
103
public func filter(_ isIncluded: (Element) throws -> Bool) rethrows -> SortedArray<Element> {
104
let newElements = try _elements.filter(isIncluded)
105
return SortedArray(sorted: newElements, areInIncreasingOrder: areInIncreasingOrder)
0 commit comments