I think I found some inconsistencies in SeqUtils.transform concerning the method characteristics().
We have:
@Override
public int characteristics() {
return delegate.characteristics() & Spliterator.ORDERED;
}
@Override
@SuppressWarnings("unchecked")
public Comparator<? super U> getComparator() {
// This implementation works with the JDK 8, as the information
// is really only used in
// java.util.stream.StreamOpFlag.fromCharacteristics(Spliterator<?> spliterator)
// Currently, the point of this method is only to be used for
// optimisations (e.g. to avoid sorting a stream twice in a row)
return (Comparator) delegate.getComparator();
}
But since in calculating the characteristics above we use bitwise AND (&) with Spliterator.ORDERED, ths Spliterator will never report Spliterator.SORTED, and so the method getComparator will never be called in StreamOpFlag.fromCharacteristics:
(characteristics & Spliterator.SORTED) != 0 && spliterator.getComparator() != null
I think characteristics() should return something like this:
public int characteristics() {
return (delegate.characteristics() | Spliterator.ORDERED) & ~(Spliterator.SIZED | Spliterator.SUBSIZED);
}
which would mean "we preserve the original characteristics, adding ORDERED if absent, and removing SIZED and SUBSIZED if present".
I think I found some inconsistencies in
SeqUtils.transformconcerning the methodcharacteristics().We have:
But since in calculating the
characteristicsabove we use bitwise AND (&) withSpliterator.ORDERED, thsSpliteratorwill never reportSpliterator.SORTED, and so the methodgetComparatorwill never be called inStreamOpFlag.fromCharacteristics:I think
characteristics()should return something like this:which would mean "we preserve the original characteristics, adding
ORDEREDif absent, and removingSIZEDandSUBSIZEDif present".