ftp.nice.ch/pub/next/science/mathematics/Random.2.0.N.bs.tar.gz#/Random2.0/Documentation/Classes/References/StandardEngine_Ref.rtf

This is StandardEngine_Ref.rtf in view mode; [Download] [Up]

Version 2.0: Written by Gregor N. Purdy.
Copyright ©1991, 1992 Contemporary Design Studios. All rights reserved.



StandardEngine 

INHERITS FROM	RandomEngine



CLASS DESCRIPTION

The StandardEngine class is a wrapper for the standard C/UNIX rand() and srand() functions supplied on the NeXT computer. An instance of the StandardEngine class can be a source of pseudorandom bits usable by the Random class.

Note that rand() generates only 31 pseudo-random bits per call and the Random class expects multiples of 8 bits. Rather than throw away 7 of the 31 bits (to leave 24), StandardEngine generates 32 words (each with 31 pseudo-random bits). One of those words is used as a source of high-order bits for the other 31. So, StandardEngine generates a unit of 31 words or 124 bytes at a shot. 

This class is part of Version 2.0 of Random, distributed 1992 May 29.

Contemporary Design Studios
2339 Woodchip Way #1B
Ypsilanti, MI 48197
313-572-1779

Gregor N. Purdy
Software Designer
University of Michigan
gregor@umich.edu

WHILE THE AUTHOR DOES WORK FOR THE UNIVERSITY OF MICHIGAN, AND PROVIDES HIS EMAIL ADDRESS AT WORK, THIS PRODUCT IS IN NO WAY AFFILIATED WITH THE UNIVERSITY OF MICHIGAN. ALL THE DESIGN, CODING, TESTING, AND DOCUMENTATION IS DONE ON THE AUTHOR'S OWN TIME.

THIS WORK IS DISTRIBUTED AS IS, WITH NO WARANTEE OR GUARANTEE EXPRESSED OR IMPLIED IN ANY RESPECT. THE AUTHOR IS NOT LIABLE FOR ANY DAMAGES WHATSOEVER DIRECTLY OR INDIRECTLY RELATED TO THE USAGE OF THIS WORK.

Comments, suggestions, and bug reports are welcome. Feel free to drop us an email or letter with your comments.

This work is distributed as FreeWare. Version 1.0 was further restricted under the GNU Public License, version 1. Version 1.1 had the same restrictions as this version. 

This version of the Random Classes may be used by anyone, anywhere, for anything, with the following conditions:
(i)	The usage must not be illegal in any way.
(ii)	You must credit Contemporary Design Studios and include the copyright information at the top of this document in your documentation and in your "Info Panel," if any, if your work is ever used by anyone other than yourself.
(iii)	Contemporary Design Studios retains the right to make improvements to this work and to change the distribution conditions and terms in future versions, including commercial derivative works.
(iv)	You may NOT in any way change the Random Classes and redistribute them, even under a new name, but you MAY, and in fact are encouraged to, report bugs and make suggestions for enhancements to Contemporary Design Studios.
(iv)	You MAY make subclasses of Random that do whatever you want. Of course, these subclasses will be governed by your own rules, but the Random Classes will still be governed by these rules.
(v)	You MAY distribute the source code of the Random Classes with your work, but if you do all the documentation for the Random Classes, including this notice, must be distributed with it. Nobody should ever see the source code to the Random Classes without also seeing these documentation files, so they can use it, too.




METHOD TYPES

Creating and freeing instances	+ alloc
- free

Generation of random bits	- makeRandom:
+ unit

Archiving	- read:
- write:



CLASS METHODS


alloc
+ alloc

Returns a new uninitialized instance.


unit
+ (int)unit

Returns the number of bytes each invocation of makeRandom: will produce. For StandardEngine, this is 124.


INSTANCE METHODS


free
- free

Frees the memory occupied by the StandardEngine instance and returns nil.


makeRandom:
- makeRandom:(uchar *)storage

Makes 32 calls to rand(), and stuffs the results into storage (note that only 31 words of pseudo-random bits are generated).


read:
- read:(NXTypedStream *)stream

Unarchives a StandardEngine from stream.

See also:  - write:


write:
- write:(NXTypedStream *)stream

Archives a StandardEngine to stream.

See also:  - read:

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.