Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3551433

Browse files
authored
Merge pull requestTheAlgorithms#710 from AnkitAtBrillio/local
Adding interface for sorting to use polymorphism features.
2 parents5227629 +ed53bd0 commit3551433

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

‎src/main/java/com/sorts/BubbleSort.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
packagesrc.main.java.com.sorts;
22

3-
publicclassBubbleSort {
3+
importsrc.main.java.com.types.Sort;
4+
5+
publicclassBubbleSort<T>implementsSort<T> {
46
/**
57
* This method implements the Generic Bubble Sort
68
*
79
* @param array The array to be sorted
810
* Sorts the array in increasing order
911
**/
12+
13+
@Override
1014
public <TextendsComparable<T>>T[]sort(T[]array) {
1115
intlast =array.length;
1216
//Sorting

‎src/main/java/com/types/Sort.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packagesrc.main.java.com.types;
2+
3+
@FunctionalInterface
4+
publicinterfaceSort<T> {
5+
6+
public <TextendsComparable<T>>T[]sort(T[]array);
7+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp