mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Formatted with Google Java Formatter
This commit is contained in:
@@ -7,26 +7,25 @@ import java.util.List;
|
||||
* The common interface of most sorting algorithms
|
||||
*
|
||||
* @author Podshivalov Nikita (https://github.com/nikitap492)
|
||||
**/
|
||||
*/
|
||||
public interface SortAlgorithm {
|
||||
|
||||
/**
|
||||
* Main method arrays sorting algorithms
|
||||
*
|
||||
* @param unsorted - an array should be sorted
|
||||
* @return a sorted array
|
||||
*/
|
||||
<T extends Comparable<T>> T[] sort(T[] unsorted);
|
||||
|
||||
/**
|
||||
* Auxiliary method for algorithms what wanted to work with lists from JCF
|
||||
*
|
||||
* @param unsorted - a list should be sorted
|
||||
* @return a sorted list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T extends Comparable<T>> List<T> sort(List<T> unsorted) {
|
||||
return Arrays.asList(sort(unsorted.toArray((T[]) new Comparable[unsorted.size()])));
|
||||
}
|
||||
/**
|
||||
* Main method arrays sorting algorithms
|
||||
*
|
||||
* @param unsorted - an array should be sorted
|
||||
* @return a sorted array
|
||||
*/
|
||||
<T extends Comparable<T>> T[] sort(T[] unsorted);
|
||||
|
||||
/**
|
||||
* Auxiliary method for algorithms what wanted to work with lists from JCF
|
||||
*
|
||||
* @param unsorted - a list should be sorted
|
||||
* @return a sorted list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T extends Comparable<T>> List<T> sort(List<T> unsorted) {
|
||||
return Arrays.asList(sort(unsorted.toArray((T[]) new Comparable[unsorted.size()])));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user