public static < E > void shuffle ( List < E > list ) { int swapPlace = - 1 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { swapPlace = ( int ) ( Math . random ( ) * ( list . size ( ) - 1 ) ) ; TrivialSwap . swap ( list , i , swapPlace ) ; } }
Randomly shuffle the elements in a list