next up previous index
Next: Unix files Up: Input/output Previous: stream_views ; view_stream   Index

Random numbers

Random numbers are supported through the random_stream interface.

In randstream.cecil:

template object random_stream isa stream[int];
method peek_next(t@:random_stream, at_end:&():int):int;
method next(t@:random_stream, at_end:&():int):int;
method is_at_end(@:random_stream):bool;
method get_rand():int;
method set_rand_seed(i:int):void;
method new_rand_stream(i:int):random_stream;
method new_rand_stream(i:int, j:int):random_stream;
method random_vector(len:int, range:int):vector[int];
A random_stream is an infinitely-long stream of ints in the range 0 to range-1 inclusive. The initial seed of the random stream can be set upon creation, to generate reproducible random streams. (But multiple random streams cannot each have their own seed set independently! There's a single global seed shared by all random streams.)


next up previous index
Next: Unix files Up: Input/output Previous: stream_views ; view_stream   Index

Cecil/Vortex Project