public abstract class IndexStream extends Object
int
s)s. The
stream ends if next()
returns -1
. Here some usage examples:
final IndexStream stream = ...;
for (int index = stream.next(); index != -1; index = stream.next()) {
System.out.println(index);
}
final IndexStream stream = ...;
int index = 0;
while ((index = stream.next()) != -1) {
System.out.println(index);
}
Modifier | Constructor and Description |
---|---|
protected |
IndexStream() |
Modifier and Type | Method and Description |
---|---|
abstract int |
next()
Return the next (positive inclusive zero) index, or -1 if the stream has
reached its end.
|
static IndexStream |
Random(int n,
double probability)
Create a new random IndexIterator.
|
static IndexStream |
Random(int n,
double p,
Random random)
Create a new random IndexIterator.
|
protected IndexStream()
public abstract int next()
public static IndexStream Random(int n, double probability)
n
- the maximal value (exclusively) the created index stream will
return.probability
- the index selection probability.IllegalArgumentException
- if n == Integer.MAX_VALUE
or
n <= 0
or the given probability
is not valid.public static IndexStream Random(int n, double p, Random random)
n
- the maximal value (exclusively) the created index stream will
return.p
- the index selection probability.random
- the random engine used for creating the random indexes.IllegalArgumentException
- if n == Integer.MAX_VALUE
or
n <= 0
or the given probability
is not valid.NullPointerException
- if the given random
engine is
null
.© 2007-2014 Franz Wilhelmstötter (2014-03-07 19:35)