Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCTAssertUnorderedEqualSequences: Improve algorithmic complexity when elements are Hashable (Resolves #176) #177

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mdznr
Copy link
Contributor

@mdznr mdznr commented Dec 21, 2021

Resolves #176

When the elements of a sequence are Hashable, use a Dictionary to keep track of the counts of elements.

The performance depends upon the input, but consistently performs better in large sequences.

chart halves

chart half

chart same

For the unit tests that this is used in, the performance wouldn’t be noticeable since it’s only ever working with small collections. However, we can probably move this to a new function that is useful outside of XCTest, like elementsEqual is to XCTAssertEqualSequences.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XCTAssertUnorderedEqualSequences: Improve algorithmic complexity when elements are Hashable
2 participants