hotbitsrandomgenerator.java

来自「java实现的遗传算法」· Java 代码 · 共 65 行

JAVA
65
字号
/*
 * This file is part of JGAP.
 *
 * JGAP offers a dual license model containing the LGPL as well as the MPL.
 *
 * For licencing information please see the file license.txt included with JGAP
 * or have a look at the top of class org.jgap.Chromosome which representatively
 * includes the JGAP license policy applicable for any file delivered with JGAP.
 */
package org.jgap.impl;

import org.jgap.*;
import org.jgap.util.*;

/**
 * Random generator using the HotBits random generators (they are pluggable
 * here) and adapts the interface to org.jgap.RandomGenerator
 *
 * @author Klaus Meffert
 * @since 2.3
 */
public class HotBitsRandomGenerator
    implements RandomGenerator {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.2 $";

  private randomX m_randomGenerator;

  public HotBitsRandomGenerator(randomX a_randomGenerator) {
    m_randomGenerator = a_randomGenerator;
  }

  public randomX getRandomGenerator() {
    return m_randomGenerator;
  }

  public byte nextByte() {
    return m_randomGenerator.nextByte();
  }

  public int nextInt() {
    return m_randomGenerator.nextInt();
  }

  public int nextInt(int ceiling) {
    return m_randomGenerator.nextInt() % ceiling;
  }

  public long nextLong() {
    return m_randomGenerator.nextLong();
  }

  public double nextDouble() {
    return m_randomGenerator.nextDouble();
  }

  public float nextFloat() {
    return m_randomGenerator.nextFloat();
  }

  public boolean nextBoolean() {
    return m_randomGenerator.nextBit();
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?