You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the (only) implementation of XCTAssertUnorderedEqualSequences (where elements are Equatable), it converts the sequence into an Array. Then it iterates through the second sequence, calling firstIndex(of:) on the first array (O(n)), which totals to O(n2). If a Set were used (when the elements are Hashable), then getting the index of an element is O(1), which would make the total algorithmic complexity O(n).
Expected behavior
XCTAssertUnorderedEqualSequences is O(n) when Element: Hashable
Actual behavior
XCTAssertUnorderedEqualSequences is O(n2) when Element: Hashable
The text was updated successfully, but these errors were encountered:
In the (only) implementation of
XCTAssertUnorderedEqualSequences
(where elements areEquatable
), it converts the sequence into anArray
. Then it iterates through the second sequence, callingfirstIndex(of:)
on the first array (O(n)), which totals to O(n2). If aSet
were used (when the elements areHashable
), then getting the index of an element is O(1), which would make the total algorithmic complexity O(n).Expected behavior
XCTAssertUnorderedEqualSequences
is O(n) whenElement: Hashable
Actual behavior
XCTAssertUnorderedEqualSequences
is O(n2) whenElement: Hashable
The text was updated successfully, but these errors were encountered: