What is meant by an "effectively unlimited stream"

I read a new enhancement in java 8 Random , and this term is effectively reused unlimited stream ,

Consider IntStream ints (int randomNumberOrigin, int randomNumberBound) :

It returns an effectively unlimited stream of pseudorandom int values, each of which corresponds to a given origin (inclusive) and associated (excluding).

Can someone explain this term.

+4
source share
1 answer

, , . , openjdk 8u40-b25 Long.MAX_VALUE :

public IntStream ints(int randomNumberOrigin, int randomNumberBound) {
    if (randomNumberOrigin >= randomNumberBound)
        throw new IllegalArgumentException(BadRange);
    return StreamSupport.intStream
            (new RandomIntsSpliterator
                     (this, 0L, Long.MAX_VALUE, randomNumberOrigin, randomNumberBound),
             false);
}

, new RandomIntsSpliterator (this, 0L, Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).

Javadoc RandomIntsSpliterator :

int. int , , , , "" Long.MAX_VALUE. " ". , .

, " " ( Long.MAX_VALUE). , , , - Long.MAX_VALUE random int, , .

ints, IntStream :

public IntStream ints(long streamSize, int randomNumberOrigin,
                      int randomNumberBound) {
    if (streamSize < 0L)
        throw new IllegalArgumentException(BadSize);
    if (randomNumberOrigin >= randomNumberBound)
        throw new IllegalArgumentException(BadRange);
    return StreamSupport.intStream
            (new RandomIntsSpliterator
                     (this, 0L, streamSize, randomNumberOrigin, randomNumberBound),
             false);
}

,

ints(min,max)

ints(Long.MAX_VALUE,min,max)

.

+5

Source: https://habr.com/ru/post/1690046/


All Articles