ftp.nice.ch/pub/next/science/mathematics/Random.2.0.N.bs.tar.gz#/Random2.0/RandomPlot/Random.h

This is Random.h in view mode; [Download] [Up]

//
// Random
//
// An Objective-C class for NeXT computers to provide services for random
// number generation.
//
// History:
//   pre 1990 Mar 23
//     Used random number generation algorithm from K&R.
//   1990 Mar 23
//     Modified to use algorithm with cycle length of 8.8 trillion.
//   1990 Mar 26
//     * Added archiving.
//     * Added randMax:, randMin:Max:, and percent:.
//   1991 Apr 26
//     * Changed to use +alloc and -init as all NeXTStep 2.0 objects should.
//   1991 May 30
//     * Prepared for distribution and initial release.
//   1991 Nov 05
//     * Added - (BOOL)bool method.
//   1991 Dec 30
//     * Changed - (float)percent to return double instead.
//     * Added - (double)randFunc: method.
//   1992 Feb 27
//     * Added Gaussian functionality.
//   1992 Apr 02
//     * New version, 2.0.
//     * New Architecture: Split generation/interpretation.
//
// Version 2.0, 1992 Apr 02 
//
// Written by Gregor Purdy
// gregor@umich.edu
//
// See the README file included for information
// and distribution and usage rights. 
//
// Copyright (C) 1992 Contemporary Design Studios. All rights reserved.
//


#import <objc/Object.h>
#import <objc/typedstream.h>
#import "RandomEngine.h"


#define RAND_RANGE	((ulong)0xffffffff)


typedef double (*ddfunc)(double);			// Double Function Returning Double.


@interface Random : Object


{
    id		engineClass;		// Class for generation.
    ulong	unit;			// Unit of generation for generation class.
    ulong	bufsize;		// unit / 8.
    uchar	*bitbuffer;		// Buffer of random bits.
    uchar	*bytebuffer;		// Buffer of random bits.
    ulong	curbit;			// Current location in the buffer.
    ulong	curbyte;		// Current location in the buffer.
    id		engine;			// The actual engine.
}


+ (int)version;				// Version of the class.

- initEngineClass:aClass;		// Use the class given for generation.
- initEngineInstance:anObject;		// Use the instance given for generation.
					//   THIS IS THE DESIGNATED INITIALIZER.

- (ulong)rand;				// Return a random integer.
- (ulong)randMax:(ulong)max;		// Return a random integer 0 <= x <= max.
- (ulong)randMin:(ulong)min		// Return a random integer min <= x <= max.
    max:(ulong)max;
- (double)percent;			// Return a random double 0.0 <= x <= 1.0.
- (BOOL)bool;				// Return randomly, YES or NO.

- (double)randFunc:(ddfunc)func;	// See description file.

- read:(NXTypedStream *)stream;		// De-archive from a typed stream.
- write:(NXTypedStream *)stream;	// Archive to a typed stream.


@end


//
// End of file.
//

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