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

HashSetCollision1 should never have a single entry #6198

Closed
scabug opened this issue Aug 6, 2012 · 2 comments
Closed

HashSetCollision1 should never have a single entry #6198

scabug opened this issue Aug 6, 2012 · 2 comments

Comments

@scabug
Copy link

scabug commented Aug 6, 2012

A set with one element should not be represented as a HashSetCollision1. If there is only one element, there can not be a collision, right?

In the example below, y should be an instance of HashSet1 instead of HashSetCollision1.

// generate hash set with a hash collision
val a = 0L
val b = 1L + (1L<<32) // Long.hashCode is just lsw xor msw
val x = HashSet(a, b)
// remove one element
val y = x - b
// resulting set is a HashSetCollision1 with one element. Huh?
println(y + " " + y.getClass) // Set(0) class scala.collection.immutable.HashSet$HashSetCollision1

@scabug
Copy link
Author

scabug commented Aug 6, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6198?orig=1
Reporter: @rklaehn
Assignee: @rklaehn
Affected Versions: 2.10.0-M6

@scabug
Copy link
Author

scabug commented Aug 6, 2012

@rklaehn said:
A pull request, as requested:
scala/scala#1071

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

No branches or pull requests

1 participant