Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/random/random-misc.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 2.4 KB
Line 
1
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
7<title>Boost Random Number Generator Library (Miscellaneous)</title>
8</head>
9
10<body bgcolor="#FFFFFF" text="#000000">
11
12<h1>Random Number Generator Library --- Miscellaneous Decorators</h1>
13
14<ul>
15<li><a href="#random_number_generator">Class template
16<code>random_number_generator</code></a>
17</ul>
18
19<h2>Introduction</h2>
20
21These decorator class templates allow adaptation of the random number
22generators and distribution functions to concepts found in the C++
23Standard Library, in particular the RandomNumberGenerator and the
24InputIterator concepts.  The latter adaptation is useful, because the
25the basic random number generators do not implement the InputIterator
26requirements per se, in contrast to the distribution functions.
27
28
29<h2><a name="synopsis">Synopsis</a> of miscellaneous decorators in
30header <code>&lt;boost/random.hpp&gt;</code></h2>
31
32<pre>
33namespace boost {
34  template&lt;class UniformRandomNumberGenerator, class IntType = long&gt;
35  class random_number_generator;
36} // namespace boost
37</pre>
38
39
40<h2><a name="random_number_generator">Class template
41<code>random_number_generator</code></a></h2>
42
43<h3>Synopsis</h3>
44<pre>
45template&lt;class UniformRandomNumberGenerator, class IntType = long&gt;
46class random_number_generator
47{
48public:
49  typedef UniformRandomNumberGenerator base_type;
50  typedef IntType argument_type;
51  typedef IntType result_type;
52  random_number_generator(base_type & rng);
53  result_type operator()(argument_type n);
54};
55</pre>
56
57<h3>Description</h3>
58
59Instantiations of class template <code>random_number_generator</code>
60model a RandomNumberGenerator (std:25.2.11 [lib.alg.random.shuffle]).
61On each invocation, it returns a uniformly distributed integer in
62the range [0..<code>n</code>).
63<p>
64The template parameter <code>IntType</code> shall denote some
65integer-like value type.
66<p>
67
68<em>Note:</em> I consider it unfortunate that the C++ Standard uses
69the name RandomNumberGenerator for something rather specific.
70
71<h3>Members</h3>
72
73<pre>random_number_generator(base_type & rng)</pre>
74
75<strong>Effects:</strong> Constructs a
76<code>random_number_generator</code> functor with the given uniform
77random number generator as the underlying source of random numbers.
78
79<pre>result_type operator()(argument_type n)</pre>
80
81<strong>Returns:</strong> The value of
82<code>uniform_int&lt;base_type&gt;(rng, 0, n-1)()</code>.
83
84<p>
85<hr>
86Jens Maurer, 2001-11-19
87
88</body>
89</html>
Note: See TracBrowser for help on using the repository browser.