mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-27 15:23:09 +00:00
676 lines
23 KiB
HTML
676 lines
23 KiB
HTML
<!DOCTYPE HTML>
|
|
<!-- NewPage -->
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Generated by javadoc -->
|
|
<title>XSTR (StructureLib 1.2.9-feature-doc.4+6626ed89ae API)</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
|
|
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.min.css" title="Style">
|
|
<link rel="stylesheet" type="text/css" href="../../../../jquery-ui.overrides.css" title="Style">
|
|
<script type="text/javascript" src="../../../../script.js"></script>
|
|
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
|
|
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
|
|
<!--[if IE]>
|
|
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
|
|
<![endif]-->
|
|
<script type="text/javascript" src="../../../../jquery/jquery-3.6.1.min.js"></script>
|
|
<script type="text/javascript" src="../../../../jquery/jquery-ui.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
try {
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="XSTR (StructureLib 1.2.9-feature-doc.4+6626ed89ae API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10};
|
|
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
|
|
var altColor = "altColor";
|
|
var rowColor = "rowColor";
|
|
var tableTab = "tableTab";
|
|
var activeTableTab = "activeTableTab";
|
|
var pathtoroot = "../../../../";
|
|
var useModuleDirectories = true;
|
|
loadScripts(document, 'script');</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<header role="banner">
|
|
<nav role="navigation">
|
|
<div class="fixedNav">
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a id="navbar.top">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a id="navbar.top.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../overview-summary.html">Overview</a></li>
|
|
<li><a href="package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?com/gtnewhorizon/structurelib/util/XSTR.html" target="_top">Frames</a></li>
|
|
<li><a href="XSTR.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<ul class="navListSearch">
|
|
<li><label for="search">SEARCH:</label>
|
|
<input type="text" id="search" value="search" disabled="disabled">
|
|
<input type="reset" id="reset" value="reset" disabled="disabled">
|
|
</li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li><a href="#field.summary">Field</a> | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li><a href="#field.detail">Field</a> | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a id="skip.navbar.top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
</div>
|
|
<div class="navPadding"> </div>
|
|
<script type="text/javascript"><!--
|
|
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
|
//-->
|
|
</script>
|
|
</nav>
|
|
</header>
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<main role="main">
|
|
<div class="header">
|
|
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">com.gtnewhorizon.structurelib.util</a></div>
|
|
<h2 title="Class XSTR" class="title">Class XSTR</h2>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<ul class="inheritance">
|
|
<li>java.lang.Object</li>
|
|
<li>
|
|
<ul class="inheritance">
|
|
<li>java.util.Random</li>
|
|
<li>
|
|
<ul class="inheritance">
|
|
<li>com.gtnewhorizon.structurelib.util.XSTR</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="description">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<dl>
|
|
<dt>All Implemented Interfaces:</dt>
|
|
<dd><code>java.io.Serializable</code></dd>
|
|
</dl>
|
|
<hr>
|
|
<pre>public class <span class="typeNameLabel">XSTR</span>
|
|
extends java.util.Random</pre>
|
|
<div class="block">XSTR - Xorshift ThermiteRandom Modified by Bogdan-G 03.06.2016 version 0.0.4</div>
|
|
<dl>
|
|
<dt><span class="seeLabel">See Also:</span></dt>
|
|
<dd><a href="../../../../serialized-form.html#com.gtnewhorizon.structurelib.util.XSTR">Serialized Form</a></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="summary">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- =========== FIELD SUMMARY =========== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="field.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Summary</h3>
|
|
<table class="memberSummary">
|
|
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colSecond" scope="col">Field</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><code>static <a href="XSTR.html" title="class in com.gtnewhorizon.structurelib.util">XSTR</a></code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#XSTR_INSTANCE">XSTR_INSTANCE</a></span></code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="constructor.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Summary</h3>
|
|
<table class="memberSummary">
|
|
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Constructor</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">XSTR</a></span>()</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Creates a new pseudo random number generator.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(long)">XSTR</a></span>​(long seed)</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Creates a new pseudo random number generator, starting with the specified seed, using
|
|
<code>setSeed(seed);</code>.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="method.summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Summary</h3>
|
|
<table class="memberSummary">
|
|
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colSecond" scope="col">Method</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tr id="i0" class="altColor">
|
|
<td class="colFirst"><code><a href="XSTR.html" title="class in com.gtnewhorizon.structurelib.util">XSTR</a></code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#clone()">clone</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i1" class="rowColor">
|
|
<td class="colFirst"><code>long</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSeed()">getSeed</a></span>()</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Returns the current state of the seed, can be used to clone the object</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i2" class="altColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#next(int)">next</a></span>​(int nbits)</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Implementation of George Marsaglia's elegant Xorshift random generator 30% faster and better quality than the
|
|
built-in java.util.random see also see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i3" class="rowColor">
|
|
<td class="colFirst"><code>boolean</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextBoolean()">nextBoolean</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i4" class="altColor">
|
|
<td class="colFirst"><code>void</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextBytes(byte%5B%5D)">nextBytes</a></span>​(byte[] bytes_arr)</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i5" class="rowColor">
|
|
<td class="colFirst"><code>double</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextDouble()">nextDouble</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i6" class="altColor">
|
|
<td class="colFirst"><code>float</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextFloat()">nextFloat</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i7" class="rowColor">
|
|
<td class="colFirst"><code>double</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextGaussian()">nextGaussian</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i8" class="altColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextInt()">nextInt</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i9" class="rowColor">
|
|
<td class="colFirst"><code>int</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextInt(int)">nextInt</a></span>​(int bound)</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Returns a pseudorandom, uniformly distributed <code>int</code> value between 0 (inclusive) and the specified value
|
|
(exclusive), drawn from this random number generator's sequence.</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="i10" class="altColor">
|
|
<td class="colFirst"><code>long</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#nextLong()">nextLong</a></span>()</code></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr id="i11" class="rowColor">
|
|
<td class="colFirst"><code>void</code></td>
|
|
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSeed(long)">setSeed</a></span>​(long seed)</code></th>
|
|
<td class="colLast">
|
|
<div class="block">Sets the seed for this pseudo random number generator.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="methods.inherited.from.class.java.util.Random">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Methods inherited from class java.util.Random</h3>
|
|
<code>doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs</code></li>
|
|
</ul>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Methods inherited from class java.lang.Object</h3>
|
|
<code>equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="details">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ============ FIELD DETAIL =========== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="field.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Field Detail</h3>
|
|
<a id="XSTR_INSTANCE">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>XSTR_INSTANCE</h4>
|
|
<pre>public static final <a href="XSTR.html" title="class in com.gtnewhorizon.structurelib.util">XSTR</a> XSTR_INSTANCE</pre>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="constructor.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Detail</h3>
|
|
<a id="<init>()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>XSTR</h4>
|
|
<pre>public XSTR()</pre>
|
|
<div class="block">Creates a new pseudo random number generator. The seed is initialized to the current time, as if by
|
|
<code>setSeed(System.currentTimeMillis());</code>.</div>
|
|
</li>
|
|
</ul>
|
|
<a id="<init>(long)">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>XSTR</h4>
|
|
<pre>public XSTR​(long seed)</pre>
|
|
<div class="block">Creates a new pseudo random number generator, starting with the specified seed, using
|
|
<code>setSeed(seed);</code>.</div>
|
|
<dl>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>seed</code> - the initial seed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
<section>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a id="method.detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Detail</h3>
|
|
<a id="nextBoolean()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextBoolean</h4>
|
|
<pre class="methodSignature">public boolean nextBoolean()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextBoolean</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextDouble()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextDouble</h4>
|
|
<pre class="methodSignature">public double nextDouble()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextDouble</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="getSeed()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>getSeed</h4>
|
|
<pre class="methodSignature">public long getSeed()</pre>
|
|
<div class="block">Returns the current state of the seed, can be used to clone the object</div>
|
|
<dl>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the current seed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="setSeed(long)">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>setSeed</h4>
|
|
<pre class="methodSignature">public void setSeed​(long seed)</pre>
|
|
<div class="block">Sets the seed for this pseudo random number generator. As described above, two instances of the same random
|
|
class, starting with the same seed, produce the same results, if the same methods are called.</div>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>setSeed</code> in class <code>java.util.Random</code></dd>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>seed</code> - the new seed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="clone()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>clone</h4>
|
|
<pre class="methodSignature">public <a href="XSTR.html" title="class in com.gtnewhorizon.structurelib.util">XSTR</a> clone()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>clone</code> in class <code>java.lang.Object</code></dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>Returns an XSRandom object with the same state as the original</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="next(int)">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>next</h4>
|
|
<pre class="methodSignature">public int next​(int nbits)</pre>
|
|
<div class="block">Implementation of George Marsaglia's elegant Xorshift random generator 30% faster and better quality than the
|
|
built-in java.util.random see also see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml</div>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>next</code> in class <code>java.util.Random</code></dd>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>nbits</code> - will shift nbits bits</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>next seed</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextGaussian()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextGaussian</h4>
|
|
<pre class="methodSignature">public double nextGaussian()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextGaussian</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextInt(int)">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextInt</h4>
|
|
<pre class="methodSignature">public int nextInt​(int bound)</pre>
|
|
<div class="block">Returns a pseudorandom, uniformly distributed <code>int</code> value between 0 (inclusive) and the specified value
|
|
(exclusive), drawn from this random number generator's sequence. The general contract of <code>nextInt</code> is that
|
|
one <code>int</code> value in the specified range is pseudorandomly generated and returned. All <code>bound</code> possible
|
|
<code>int</code> values are produced with (approximately) equal probability. The method <code>nextInt(int bound)</code> is
|
|
implemented by class <code>Random</code> as if by:
|
|
|
|
<pre>
|
|
<code>
|
|
public int nextInt(int bound) {
|
|
if (bound <= 0)
|
|
throw new IllegalArgumentException("bound must be positive");
|
|
|
|
if ((bound & -bound) == bound) // i.e., bound is a power of 2
|
|
return (int)((bound * (long)next(31)) >> 31);
|
|
|
|
int bits, val;
|
|
do {
|
|
bits = next(31);
|
|
val = bits % bound;
|
|
} while (bits - val + (bound-1) < 0);
|
|
return val;
|
|
}</code>
|
|
</pre>
|
|
|
|
<p>
|
|
The hedge "approx imately" is used in the foregoing description only because the next method is only
|
|
approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen
|
|
bits, then the algorithm shown would choose <code>int</code> values from the stated range with perfect uniformity.
|
|
<p>
|
|
The algorithm is slightly tricky. It rejects values that would result in an uneven distribution (due to the fact
|
|
that 2^31 is not divisible by n). The probability of a value being rejected depends on n. The worst case is
|
|
n=2^30+1, for which the probability of a reject is 1/2, and the expected number of iterations before the loop
|
|
terminates is 2.
|
|
<p>
|
|
The algorithm treats the case where n is a power of two specially: it returns the correct number of high-order
|
|
bits from the underlying pseudo-random number generator. In the absence of special treatment, the correct number
|
|
of <i>low-order</i> bits would be returned. Linear congruential pseudo-random number generators such as the one
|
|
implemented by this class are known to have short periods in the sequence of values of their low-order bits.
|
|
Thus, this special case greatly increases the length of the sequence of values returned by successive calls to
|
|
this method if n is a small power of two.</div>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextInt</code> in class <code>java.util.Random</code></dd>
|
|
<dt><span class="paramLabel">Parameters:</span></dt>
|
|
<dd><code>bound</code> - the upper bound (exclusive). Must be positive.</dd>
|
|
<dt><span class="returnLabel">Returns:</span></dt>
|
|
<dd>the next pseudorandom, uniformly distributed <code>int</code> value between zero (inclusive) and <code>bound</code>
|
|
(exclusive) from this random number generator's sequence</dd>
|
|
<dt><span class="throwsLabel">Throws:</span></dt>
|
|
<dd><code>java.lang.IllegalArgumentException</code> - if bound is not positive</dd>
|
|
<dt><span class="simpleTagLabel">Since:</span></dt>
|
|
<dd>1.2</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextInt()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextInt</h4>
|
|
<pre class="methodSignature">public int nextInt()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextInt</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextFloat()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextFloat</h4>
|
|
<pre class="methodSignature">public float nextFloat()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextFloat</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextLong()">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>nextLong</h4>
|
|
<pre class="methodSignature">public long nextLong()</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextLong</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
<a id="nextBytes(byte[])">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>nextBytes</h4>
|
|
<pre class="methodSignature">public void nextBytes​(byte[] bytes_arr)</pre>
|
|
<dl>
|
|
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
|
|
<dd><code>nextBytes</code> in class <code>java.util.Random</code></dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<footer role="contentinfo">
|
|
<nav role="navigation">
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a id="navbar.bottom">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a id="navbar.bottom.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../overview-summary.html">Overview</a></li>
|
|
<li><a href="package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?com/gtnewhorizon/structurelib/util/XSTR.html" target="_top">Frames</a></li>
|
|
<li><a href="XSTR.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li><a href="#field.summary">Field</a> | </li>
|
|
<li><a href="#constructor.summary">Constr</a> | </li>
|
|
<li><a href="#method.summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li><a href="#field.detail">Field</a> | </li>
|
|
<li><a href="#constructor.detail">Constr</a> | </li>
|
|
<li><a href="#method.detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a id="skip.navbar.bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
</nav>
|
|
</footer>
|
|
</body>
|
|
</html>
|