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

SetWrapper does not preserve performance / behavior #6364

Closed
scabug opened this issue Sep 11, 2012 · 2 comments
Closed

SetWrapper does not preserve performance / behavior #6364

scabug opened this issue Sep 11, 2012 · 2 comments

Comments

@scabug
Copy link

@scabug scabug commented Sep 11, 2012

{code}val aScalaSet = Set(1,2,3)
val wrappedSet = new SetWrapper(aScalaSet)

aScalaSet.contains(2) // operation in O(1)
wrappedSet.contains(2) // operation in O(n){code}

Since SetWrapper is not implementing additional methods in top of {code}size(){code} and {code}iterator(){code}, the performance of the wrapped collection is hindered. There are at least 2 issues with that:

  • Neither the wrap semantic or the documentation is indicating this behavior degradation, leaving the user with false assumptions
  • It obviously kill performance when working with large collections

This problem might as well be present in other type of collections.

Suggested resolution: make SetWrapper implements all the java interface set methods that would incur in a loss of performance.

@scabug
Copy link
Author

@scabug scabug commented Sep 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6364?orig=1
Reporter: Julien Letrouit (jletroui)
Affected Versions: 2.9.1, 2.9.2, 2.10.0-M7, 2.11.0-M1

@scabug
Copy link
Author

@scabug scabug commented Jan 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants