Characteristics of an empty spliterator

Paul Sandoz paul.sandoz at oracle.com
Tue Mar 26 04:21:23 PDT 2013


Hi Dmitry,

We definitely need to document what characteristics should be reported for empty spliterators. Thanks for raising this.

The reason why i included SUBSIZED, even though the spliterator does not split, is because some computation decisions might be made by looking first at the characteristics and then looking at the size later on. And the spec does not rule out that a zero sized spliterator cannot be further split. It very much depends on the underlying data structure. However, in this case we should also document that this spliterator does not split. 

Paul.

On Mar 26, 2013, at 11:55 AM, Dmitry Bessonov <dmitry.bessonov at oracle.com> wrote:

> Hello,
> 
> I wonder what are the expected characteristics of empty spliterators?
> Having SIZED and not having INFINITE is logical.
> 
> What about SUBSIZED characteristic
> which the current implementation gives to an empty spliterator?
> 
>     /**
>      * Characteristic value signifying that this, and all Spliterators
>      * resulting from {@code trySplit()}, as well as any that they in
>      * turn split, are {@link #SIZED}.  .......
>      */
>     public static final int SUBSIZED = 0x00010000;
> 
> Current behavior of method trySplit() of an empty spliterator
> indicates that it could not be ever split.
> So this seems like a spec contradiction.
> 
> 
> May it make sense to specify characteristics of an empty spliterator 
> explicitly?
> 
> -Dmitry
> 
> 



More information about the lambda-dev mailing list