Merge pull request #710 from AnkitAtBrillio/local

Adding interface for sorting to use polymorphism features.
This commit is contained in:
yanglbme 2019-03-03 09:31:36 +08:00 committed by GitHub
commit 3551433e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -1,12 +1,16 @@
package src.main.java.com.sorts;
public class BubbleSort {
import src.main.java.com.types.Sort;
public class BubbleSort<T> implements Sort<T> {
/**
* This method implements the Generic Bubble Sort
*
* @param array The array to be sorted
* Sorts the array in increasing order
**/
@Override
public <T extends Comparable<T>> T[] sort(T[] array) {
int last = array.length;
//Sorting

View File

@ -0,0 +1,7 @@
package src.main.java.com.types;
@FunctionalInterface
public interface Sort<T> {
public <T extends Comparable<T>> T[] sort(T[] array);
}