comparison java/src/java/util/Random.d @ 21:9b96950f2c3c

the 'java' tree compiles on both D1-Tango and D2-Phobos
author Frank Benoit <benoit@tionex.de>
date Thu, 19 Mar 2009 20:38:55 +0100
parents bc29606a740c
children
comparison
equal deleted inserted replaced
20:dccb717aa902 21:9b96950f2c3c
1 module java.util.Random; 1 module java.util.Random;
2 2
3 import java.lang.all; 3 import java.lang.all;
4 static import tango.math.random.Kiss; 4 version(Tango){
5 static import tango.math.random.Kiss;
6 } else { // Phobos
7 static import std.random;
8 }
5 9
6 class Random { 10 class Random {
7 tango.math.random.Kiss.Kiss kiss; 11 version(Tango){
12 tango.math.random.Kiss.Kiss kiss;
13 } else { // Phobos
14 std.random.MinstdRand gen;
15 }
8 16
9 public this(int seed ){ 17 public this(int seed ){
10 kiss.seed(seed); 18 version(Tango){
19 kiss.seed(seed);
20 } else { // Phobos
21 gen.seed( seed );
22 }
11 } 23 }
12 public bool nextBoolean(){ 24 public bool nextBoolean(){
13 return kiss.toInt(2) is 0; 25 version(Tango){
26 return kiss.toInt(2) is 0;
27 } else { // Phobos
28 return (gen.next() & 1 ) is 0;
29 }
14 } 30 }
15 } 31 }
16 32
17 33