|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcz.zcu.fav.kiv.jsim.random.JSimUserObjectStream
A stream generating user-defined objects according to their corresponding user-defined absolute rates. The probability that a certain object will be returned by the getNext() method is equal to the ratio its_absolute_rate / sum_of_all_absolute_rates. All objects specified by the user must be non-null, all absolute rates must be non-negative. An initial seed can be specified, which allows you to generate the same sequence of user objects several times.
| Field Summary | |
protected java.util.Random |
stream
An internal stream from which random numbers are taken to compute an object. |
| Constructor Summary | |
JSimUserObjectStream(java.lang.Object[] objects,
double[] rates)
Creates a new user object stream. |
|
JSimUserObjectStream(java.lang.Object[] objects,
double[] rates,
long seed)
Creates a new user object stream. |
|
| Method Summary | |
java.lang.Object |
getNext()
Returns a randomly selected user object. |
java.lang.Object[] |
getObjects()
Returns a copy of user objects returned by getNext(). |
double[] |
getRates()
Returns a copy of rates used by the generator. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.Random stream
| Constructor Detail |
public JSimUserObjectStream(java.lang.Object[] objects,
double[] rates)
throws JSimInvalidParametersException
objects - User objects to be returned by getNext(). No object of the array can be null.
The length of the array must be positive and equal to the lenght of rates.rates - The absolute rates of occurence of user-defined objects. Every rate must be
non-negative. The length of the array must be positive and equal to the lenght
of objects.
JSimInvalidParametersException - This exception is thrown out if the arrays of objects
and rates are null, have zero length, have different
lengths, or an item of the arrays is null or less than
zero, respectively.
public JSimUserObjectStream(java.lang.Object[] objects,
double[] rates,
long seed)
throws JSimInvalidParametersException
objects - User objects to be returned by getNext(). No object of the array can be null.
The length of the array must be positive and equal to the lenght of rates.rates - The absolute rates of occurence of user-defined objects. Every rate must be
non-negative. The length of the array must be positive and equal to the lenght
of objects.seed - A seed that will initialize the generator.
JSimInvalidParametersException - This exception is thrown out if the arrays of objects
and rates are null, have zero length, have different
lengths, or an item of the arrays is null or less than
zero, respectively.| Method Detail |
public java.lang.Object getNext()
public java.lang.Object[] getObjects()
public double[] getRates()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||