📄 classprandom.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PRandom class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>PRandom Class Reference</h1><code>#include <<a class="el" href="random_8h-source.html">random.h</a>></code><p><a href="classPRandom-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPRandom.html#a0">PRandom</a> ()</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPRandom.html#a1">PRandom</a> (DWORD seed)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPRandom.html#a2">SetSeed</a> (DWORD seed)</td></tr><tr><td nowrap align=right valign=top>unsigned </td><td valign=bottom><a class="el" href="classPRandom.html#a3">Generate</a> ()</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPRandom.html#a4">operator unsigned</a> ()</td></tr><tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr><tr><td nowrap align=right valign=top>unsigned </td><td valign=bottom><a class="el" href="classPRandom.html#d0">Number</a> ()</td></tr><tr><td colspan=2><br><h2>Protected Types</h2></td></tr><tr><td nowrap align=right valign=top>enum </td><td valign=bottom>{ <a class="el" href="classPRandom.html#t2t0">RandBits</a> = 8, <a class="el" href="classPRandom.html#t2t1">RandSize</a> = 1<<RandBits }</td></tr><tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n0">randcnt</a></td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n1">randrsl</a> [RandSize]</td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n2">randmem</a> [RandSize]</td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n3">randa</a></td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n4">randb</a></td></tr><tr><td nowrap align=right valign=top>DWORD </td><td valign=bottom><a class="el" href="classPRandom.html#n5">randc</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>Mersenne Twister random number generator. An application would create a static instance of this class, and then use if to generate a sequence of psuedo-random numbers.<p>Usually an application would simply use <a class="el" href="classPRandom.html#d0">PRandom::Number()</a> but if performance is an issue then it could also create a static local variable such as: { static PRandom rand; for (i = 0; i < 10000; i++) array[i] = rand; }<p>This method is not thread safe, so it is the applications responsibility to assure that its calls are single threaded. <p><hr><h2>Member Enumeration Documentation</h2><a name="t2" doxytag="PRandom::@23"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> anonymous enum<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b>Enumeration values: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em><a name="t2t0" doxytag="RandBits"></a><em>RandBits</em></em> </td><td></td></tr><tr><td valign=top><em><a name="t2t1" doxytag="RandSize"></a><em>RandSize</em></em> </td><td></td></tr></table></dl> </td> </tr></table><hr><h2>Constructor & Destructor Documentation</h2><a name="a0" doxytag="PRandom::PRandom"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PRandom::PRandom </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Construct the random number generator. This version will seed the random number generator with a value based on the system time as returned by time() and clock(). </td> </tr></table><a name="a1" doxytag="PRandom::PRandom"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PRandom::PRandom </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">DWORD </td> <td class="mdname1" valign="top" nowrap> <em>seed</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Construct the random number generator. This version allows the application to choose the seed, thus letting it get the same sequence of values on each run. Useful for debugging. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>seed</em> </td><td>New seed value, must not be zero </td></tr></table></dl> </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="a3" doxytag="PRandom::Generate"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> unsigned PRandom::Generate </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the next psuedo-random number in sequence. This generates one pseudorandom unsigned integer (32bit) which is uniformly distributed among 0 to 2^32-1 for each call. </td> </tr></table><a name="d0" doxytag="PRandom::Number"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> unsigned PRandom::Number </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [static]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the next psuedo-random number in sequence. This utilises a single system wide thread safe PRandom variable. All threads etc will share the same psuedo-random sequence. </td> </tr></table><a name="a4" doxytag="PRandom::operator unsigned"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PRandom::operator unsigned </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the next psuedo-random number in sequence. </td> </tr></table><a name="a2" doxytag="PRandom::SetSeed"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void PRandom::SetSeed </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">DWORD </td> <td class="mdname1" valign="top" nowrap> <em>seed</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Set the seed for the random number generator. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>seed</em> </td><td>New seed value, must not be zero </td></tr></table></dl> </td> </tr></table><hr><h2>Member Data Documentation</h2><a name="n3" doxytag="PRandom::randa"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randa<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="n4" doxytag="PRandom::randb"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randb<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="n5" doxytag="PRandom::randc"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randc<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="n0" doxytag="PRandom::randcnt"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randcnt<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="n2" doxytag="PRandom::randmem"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randmem[RandSize]<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="n1" doxytag="PRandom::randrsl"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DWORD PRandom::randrsl[RandSize]<code> [protected]</code> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><hr>The documentation for this class was generated from the following file:<ul><li><a class="el" href="random_8h-source.html">random.h</a></ul><hr><address style="align: right;"><small>Generated on Wed Sep 29 22:44:18 2004 for PWLib by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -