public int next ( ) { // int rndIndex = (int) ((array.length - 1 - curIndex) * rg.nextDouble()) // + curIndex; // int tmp = array[rndIndex]; // array[rndIndex] = array[curIndex]; // array[curIndex] = tmp; // curIndex++; // // return tmp; int number ; do { number = rg . nextInt ( size ) + 1 ; } while ( ! numberSet . add ( number ) ) ; return number ; }
Not repeat randomly choose a number from 1 to the initinalized size