RandomRemoveResult < E > function ( Random arg0 , List < E > arg1 ) { int loc0 = arg1 . loc0 ( ) ; if ( loc0 == 0 ) return null ; if ( loc0 == 1 ) { E loc1 = arg1 . remove ( 0 ) ; return new RandomRemoveResult < E > ( loc1 , loc1 ) ; } int loc2 = arg0 . nextInt ( loc0 ) ; E loc3 = arg1 . get ( loc2 ) ; return new RandomRemoveResult < E > ( loc3 , removeBySwapLast ( arg1 , loc2 ) ) ; }
removes random element from list by swapping with last element . o 1 moves . this method is useful with arraylist-alike containers with o 1 get index and o n remove index when keeping array order is not important . not synchronized even with synchronized containers ! . warning : amount of fetched random data is implementation-defined concode_field_sep E removed concode_elem_sep E moved concode_field_sep boolean removeBySwapLast concode_elem_sep E removeBySwapLast concode_elem_sep E removeRandomBySwapLastSimple