Closed techsy730 closed 3 years ago
What does the JDK do?
The JDK actually had none of Iterator
, Spliterator
, or Stream
concatenation functions. Guava does have Stream concatenation; I am taking a look at what they do now.
Ok, so what Guava does is to only allow ORDERED | SIZED | NONNULL to be reported by the underlying concat'ed spliterator, and only if all sub-spliterators do as well.
I think that may be too restrictive for us (this implementation will correctly handle SUBSIZED for example).
I'd let you decide which properties filter to the concatenation—you wrote the code...
The SORTED and DISTINCT property do not combine. For example: (assume there is a hypothetical
SortedSet.of
, which there isn't at the time of this writing)Now both split1 and split2 report NONNULL | SIZED | ORDERED | SORTED | DISTINCT as their characteristics. As such, so does the combined spliterator. But the combined spliterator will give the elements {1, 2, 3, 1, 4, 6}, and that is neither SORTED nor DISTINCT.
The fix is to make Spliterators.SpliteratorConcatenator#computeCharacteristics never set the SORTED or DISTINCT bits even if all child spliterators do.