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

SetWrapper does not preserve performance / behavior

    Details

      Description

      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)

      Since SetWrapper is not implementing additional methods in top of

      size()
      and
      iterator()
      , 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.

        Activity

        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/3302

          People

          • Assignee:
            Rex Kerr
            Reporter:
            Julien Letrouit
          • Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development