1 package org.jgap.util; 2 3 4 import org.jgap.*; 5 6 import java.util.Random ; 7 8 20 public class randomJava extends randomX { 21 22 private Random r; 23 private int ibytes = 0; 24 25 27 29 30 public randomJava() { 31 34 r = new Random (); 35 } 36 37 42 43 public randomJava(long seed) { 44 r = new Random (seed); 45 } 46 47 52 53 public void setSeed(long seed) { 54 super.setSeed(); r.setSeed(seed); 56 ibytes = 0; } 58 59 private int idat; 60 61 68 69 public byte nextByte() { 70 byte d; 71 72 if (ibytes <= 0) { 73 idat = r.nextInt(); 74 ibytes = 4; 75 } 76 d = (byte) idat; 77 idat >>= 8; 78 ibytes--; 79 return d; 80 } 81 }; 82 | Popular Tags |