Merge pull request #710 from AnkitAtBrillio/local
Adding interface for sorting to use polymorphism features.
This commit is contained in:
commit
3551433e46
@ -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
|
||||
|
7
src/main/java/com/types/Sort.java
Normal file
7
src/main/java/com/types/Sort.java
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user