View Javadoc

1   /*
2    * @(#)StreamInterface.java 21-08-2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.jstats.streams;
11  
12  import java.io.Serializable;
13  
14  /***
15   * The StreamInterface defines the streams to be used within the JSTATS package.
16   * Potential implementations include the pseudo random stream, the fully
17   * one-time random stream, etc.
18   * <p>
19   * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
20   * University of Technology </a>, the Netherlands. <br>
21   * See for project information <a
22   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
23   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24   * License (GPL) </a>, no warranty <br>
25   * 
26   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
27   *         Jacobs </a>
28   * @version 1.8, 2004-03-20
29   * @since 1.0
30   */
31  public interface StreamInterface extends Serializable
32  {
33  	/***
34  	 * Returns the next pseudorandom, uniformly distributed <code>boolean</code>
35  	 * value from this random number generator's sequence. The general contract
36  	 * of <tt>nextBoolean</tt> is that one <tt>boolean</tt> value is
37  	 * pseudorandomly generated and returned. The values <code>true</code> and
38  	 * <code>false</code> are produced with (approximately) equal probability.
39  	 * The method <tt>nextBoolean</tt> is implemented by class <tt>Random</tt>
40  	 * as follows: <blockquote>
41  	 * 
42  	 * <pre>
43  	 * public boolean nextBoolean()
44  	 * {
45  	 * 	return next(1) != 0;
46  	 * }
47  	 * </pre>
48  	 * 
49  	 * </blockquote>
50  	 * 
51  	 * @return the next pseudorandom, uniformly distributed <code>boolean</code>
52  	 *         value from this random number generator's sequence.
53  	 * @since 1.2
54  	 */
55  	boolean nextBoolean();
56  
57  	/***
58  	 * Method return a (pseudo)random number from the stream over the interval
59  	 * (0,1) using this stream, after advancing its state by one step.
60  	 * 
61  	 * @return double the (pseudo)random number
62  	 */
63  	double nextDouble();
64  
65  	/***
66  	 * Method return a (pseudo)random number from the stream over the interval
67  	 * (0,1) using this stream, after advancing its state by one step.
68  	 * 
69  	 * @return float the (pseudo)random number
70  	 */
71  	float nextFloat();
72  
73  	/***
74  	 * Method return a (pseudo)random number from the stream over using this
75  	 * stream, after advancing its state by one step.
76  	 * 
77  	 * @return int the (pseudo)random number
78  	 */
79  	int nextInt();
80  
81  	/***
82  	 * Method returns (pseudo)random number from the stream over the integers i
83  	 * and j .
84  	 * 
85  	 * @param i the minimal value
86  	 * @param j the maximum value
87  	 * @return int
88  	 */
89  	int nextInt(int i, int j);
90  
91  	/***
92  	 * Method return a (pseudo)random number from the stream over using this
93  	 * stream, after advancing its state by one step.
94  	 * 
95  	 * @return long the (pseudo)random number
96  	 */
97  	long nextLong();
98  
99  	/***
100 	 * returns the seed of the generator
101 	 * 
102 	 * @return long the seed
103 	 */
104 	long getSeed();
105 
106 	/***
107 	 * sets the seed of the generator
108 	 * 
109 	 * @param seed the new seed
110 	 */
111 	void setSeed(final long seed);
112 	
113 	/***
114 	 * resets the stream
115 	 */
116 	void reset();
117 }