Scala Programming Language
  1. Scala Programming Language
  2. SI-6198

HashSetCollision1 should never have a single entry

    Details

      Description

      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

        Issue Links

          Activity

          Hide
          Rüdiger Klaehn added a comment -

          A pull request, as requested:
          https://github.com/scala/scala/pull/1071

          Show
          Rüdiger Klaehn added a comment - A pull request, as requested: https://github.com/scala/scala/pull/1071

            People

            • Assignee:
              Rüdiger Klaehn
              Reporter:
              Rüdiger Klaehn
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development