Boost logo

Boost :

From: Kevlin Henney (Kevlin.Henney_at_[hidden])
Date: 1998-12-07 13:44:44


I was planning to submit a generalised random number
iterator/pseudo-container that I wrote over 3 years ago to the library. It
was distributed with ACCU's Overload as an example of how the
container/iterator concept can be generalised.

It is based on the linear feedback shift register described by Bruce
Schneier in "Pseudo-random_numbers sequence generator for 32-bit CPUs", DDJ
February 1992. There is a bit iterator that actually has the intelligence
and produces random bits according to this algorithm. The 'container'
notionally represents the seed of the sequence and an optional bounding
length, and is used to source iterators that dereference to unsigned long
-- the iterator simply collects the random bits. The iterators are best
classified as forward iterators to const.

The updated model I was proposing (in fact, I discovered, I proposed it in
the comments to the existing implementation from May '95!) would allow
templates for the integer type parameterised, eg unsigned short, and the
bit iterator would simply become the bool specialisation.

I am keen to put this code forward, as it is in fact an example of freely
available software that has already solved the issues and been used in
commercial code (at least one known use other than by its author ;->). What
do others think?

Kevlin

Beman Dawes <beman_at_[hidden]> on 06/12/98 14:39:13

Please respond to boost_at_[hidden]

To: boost_at_[hidden]
cc: (bcc: Kevlin Henney/QA Training Ltd)
Subject: [boost] Re: www.boost.org updated

At 07:41 PM 12/4/98 -0700, Greg wrote:

>It looks really good up there. Do I get my picture in cyberspace
too?

Anybody who contributes anything gets their picture in cyberspace!
(Unless they are shy.)

>At some point (after we ship Oracle8i) I'll think some more about
some
>random iterators.

The background on the above is that when Greg looked at my min_rand
class, he commented that it was very close to being useful as an STL
compliant input iterator.

I tried to work that out, but got hung up on termination. For
example, if you wanted 1000 random numbers in a vector, you could
write something like:

   min_rand rng;
   vector<long> vec( rng, ??? ); // oops! no way to specify end

A third container-like class is needed, I think. end() would return
0,
begin() would return an iterator with operator++() which returned
++rng for 1000 calls, then returned 0:

   min_rand rng;
   iter_counter itrc( rng, 1000 );
   vector<long> vec( itrc.begin(), itrc.end() );

Anyhow, that is the problem Greg is thinking about.

--Beman

------------------------------------------------------------------------
More trinkets than the 1996 Olympics. Fewer lines than the Goodwill Games
ESPN gear, SportsCenter gear, NBA NHL MLB NCAA NFL gear, Memorabilia
http://ads.egroups.com/click/147/1

Free Web-based e-mail groups -- http://www.eGroups.com

------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk