eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

ImmutableSortedBagImpl.distinctView() should return a more efficient implementation

Open victornoel opened this issue 3 years ago • 0 comments

As discussed in #1210, ImmutableSortedBagImpl.distinctView() was implemented by returning a simple ArrayAdapter over the internal array of the bag.

This means we don't take advantage of the comparator that guarantees the order of the elements of the array.

Taking advantage of it would improve performances for methods like contains().

Alternative solution for this would be:

  • rely on ImmutableTreeSet as it has the same internal guarantees as what we want, but the issue is that it would need to expose publicly a way to instantiate it with an array
  • introduce another implementation (maybe to be shared with ImmutableTreeSet?)

victornoel avatar Apr 05 '22 16:04 victornoel