package com.goafanti.common.utils;

import java.util.Random;

public class RandomUtil {
	public static int[] generateRandomList(int maxNum, int count) {
		int[] res = new int[count];
		Random rand = new Random();

		boolean flag = false;
		int randInt = 0;
		if(maxNum < count){
			for (int i = 0; i < count; i++) {
				res[i] = i;
			}
		}else {
			for (int i = 0; i < count; i++) {
				res[i]=-1;
				do {
					randInt = rand.nextInt(maxNum);
					for (int i1 = 0; i1 < count; i1++) {
						if (res[i1] == randInt) {
							flag = false;
							break;
						}
						flag=true;
					}
				} while (!flag);
				flag = false;
				res[i] = randInt;
			}
		}
		return res;
	}
	


}
