This project contains a library that uses dynamic creation of sorting functions that belong in the comparison model according to needs. The use of callbacks avoids a lot of branches, which in turn offers a balanced tradeoff between flexibility and performance when handling big arrays and need several algorithms or sorting orders.
- Creating a useful library
- Learning lambdas and callbacks in java
- Homework of neapolis algorithms class
With src/sorting_machine in your project:
import sorting_machine.SortingMachine;
import sorting_machine.SortingOrderChoices;
import sorting_machine.SortingAlgorithmChoices;
public class Example{
SortingMachine<YOUR_TYPE> sortingMachine = new SortingMachine<>(SortingAlgorithmsChoices.BUBBLE_SORT, SortingOrderChoices.ASCENDING);
long steps = sortingMachine.sort(YOUR_ARRAY_OF_TYPE);
}