(T[] array)
| 10 | public class SwapSort implements SortAlgorithm { |
| 11 | |
| 12 | @Override |
| 13 | public <T extends Comparable<T>> T[] sort(T[] array) { |
| 14 | int index = 0; |
| 15 | |
| 16 | while (index < array.length - 1) { |
| 17 | final int amountSmallerElements = this.getSmallerElementCount(array, index); |
| 18 | |
| 19 | if (amountSmallerElements > 0) { |
| 20 | SortUtils.swap(array, index, index + amountSmallerElements); |
| 21 | } else { |
| 22 | index++; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | return array; |
| 27 | } |
| 28 | |
| 29 | private <T extends Comparable<T>> int getSmallerElementCount(final T[] array, final int index) { |
| 30 | int counter = 0; |
nothing calls this directly
no test coverage detected