// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
//   if (predicate.test(value)) {
//     return value;
//   } else {
//     throw new IllegalArgumentException();
//   }
// }


import static be.fror.common.base.Preconditions.checkArgument;
import static java.lang.Math.max;
import java.util.Random;
/*
 * Copyright 2015 Olivier Grégoire <ogregoire@users.noreply.github.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package be.fror.common.random;



/**
 *
 * @author Olivier Grégoire <ogregoire@users.noreply.github.com>
 */
public final class MersenneTwister extends Random {

  private static final int N = 624;
  private static final int M = 397;
  private static final int UPPER_MASK = 0x80000000;
  private static final int LOWER_MASK = 0x7fffffff;

  private static final int[] ZERO_OR_MATRIX = {0x0, 0x9908b0df};

  private static final int MASK_A = 0x9d2c5680;
  private static final int MASK_B = 0xefc60000;

  private int[] MT;
  private int index;

  public MersenneTwister() {
  }

  public MersenneTwister(long seed) {
    setSeed(seed);
  }

  public MersenneTwister(int[] seed) {
    setSeed(seed);
  }

  @Override
  public synchronized void setSeed(long seed) {
    MT = new int[N];
    MT[0] = (int) seed;
    for (int i = 1; i < N; i++) {
      MT[i] = (0x6c078965 * (MT[i - 1] ^ (MT[i - 1] >>> 30)) + i);
    }
    index = N;
  }

  public synchronized void setSeed(int[] seed) {
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
//   if (predicate.test(value)) {
//     return value;
//   } else {
//     throw new IllegalArgumentException();
//   }
// }


// Path: src/main/java/be/fror/common/random/MersenneTwister.java
import static be.fror.common.base.Preconditions.checkArgument;
import static java.lang.Math.max;
import java.util.Random;

/*
 * Copyright 2015 Olivier Grégoire <ogregoire@users.noreply.github.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package be.fror.common.random;



/**
 *
 * @author Olivier Grégoire <ogregoire@users.noreply.github.com>
 */
public final class MersenneTwister extends Random {

  private static final int N = 624;
  private static final int M = 397;
  private static final int UPPER_MASK = 0x80000000;
  private static final int LOWER_MASK = 0x7fffffff;

  private static final int[] ZERO_OR_MATRIX = {0x0, 0x9908b0df};

  private static final int MASK_A = 0x9d2c5680;
  private static final int MASK_B = 0xefc60000;

  private int[] MT;
  private int index;

  public MersenneTwister() {
  }

  public MersenneTwister(long seed) {
    setSeed(seed);
  }

  public MersenneTwister(int[] seed) {
    setSeed(seed);
  }

  @Override
  public synchronized void setSeed(long seed) {
    MT = new int[N];
    MT[0] = (int) seed;
    for (int i = 1; i < N; i++) {
      MT[i] = (0x6c078965 * (MT[i - 1] ^ (MT[i - 1] >>> 30)) + i);
    }
    index = N;
  }

  public synchronized void setSeed(int[] seed) {
    checkArgument(seed.length != 0);