Randomize the order of the list elements. @webref intlist:method @webBrief Randomize the order of the list elements
()
| 644 | * @webBrief Randomize the order of the list elements |
| 645 | */ |
| 646 | @SuppressWarnings("unused") |
| 647 | public void shuffle() { |
| 648 | Random r = new Random(); |
| 649 | int num = count; |
| 650 | while (num > 1) { |
| 651 | int value = r.nextInt(num); |
| 652 | num--; |
| 653 | int temp = data[num]; |
| 654 | data[num] = data[value]; |
| 655 | data[value] = temp; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | |
| 660 | /** |
no test coverage detected