Sorts the given array using the BeadSort algorithm. @param array The array of non-negative integers to be sorted. @return The sorted array. @throws IllegalArgumentException If the array contains negative numbers.
(int[] array)
| 13 | * @throws IllegalArgumentException If the array contains negative numbers. |
| 14 | */ |
| 15 | public int[] sort(int[] array) { |
| 16 | allInputsMustBeNonNegative(array); |
| 17 | return extractSortedFromGrid(fillGrid(array)); |
| 18 | } |
| 19 | |
| 20 | private void allInputsMustBeNonNegative(final int[] array) { |
| 21 | if (Arrays.stream(array).anyMatch(s -> s < 0)) { |