On Tue, 2 Dec 2025 09:09:35 GMT, Patrick Strawderman <[email protected]> wrote:

>> I noticed that the Spliterator for EnumSet does not report SORTED, ORDERED, 
>> or NONNULL characteristics, all of which are inherent to API of EnumSet. I 
>> found there's an existing ticket for this as well.
>> 
>> The ticket also mentions optimized `forEach`, etc, which I presume means 
>> avoiding the default implementation that uses the iterator and just 
>> iterating over the bitset directly; I can add that here or perhaps in a 
>> follow up if it's still deemed worthwhile.
>
> Patrick Strawderman has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Add unit test

test/jdk/java/util/EnumSet/EnumSetSpliteratorTest.java line 79:

> 77:         assertTrue(spliterator.hasCharacteristics(Spliterator.SORTED), 
> "Missing SORTED");
> 78:         assertTrue(spliterator.hasCharacteristics(Spliterator.ORDERED), 
> "Missing ORDERED");
> 79:         assertTrue(spliterator.hasCharacteristics(Spliterator.NONNULL), 
> "Missing NONNULL");

Thanks for adding the test. I think it makes sense to check the 
`enumSet.spliterator().characteristics()` being exactly `DISTINCT | SORTED | 
ORDERED | NONNULL` (since this test otherwise would still pass if further 
characteristics are added).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28568#discussion_r2581832277

Reply via email to