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
- 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.