I'm moving some code to use OrderedSet and noticed it is missing a filter operation.
Previous code:
// 1) we remove any registrations that it hosted
let registrations: Set<VersionedRegistration> = self._registrations.removeValue(forKey: key) ?? []
let remainingRegistrations: Set<VersionedRegistration> = registrations.filter { registration in
registration.actorID.uniqueNode != node
}
this was ok, since we call the filter on:
extension Set {
@available(swift 4.0)
@inlinable public func filter(_ isIncluded: (Element) throws -> Bool) rethrows -> Set<Element>
}
but it seems that OrderedSet is missing this specialization, so we fallback to calling the Sequence's impl:
@inlinable public func filter(_ isIncluded: (Self.Element) throws -> Bool) rethrows -> [Self.Element]
returning an array -- which is a bit meh, since we have to convert back into the OrderedSet.
Feature Request
Please provide a filter similar to how Set does that keeps the collection type OrderedSet -> OrderedSet