Skip to content

Commit 5f39421

Browse files
added .lessOrEqual to Sortable
1 parent 3e3d1e4 commit 5f39421

File tree

1 file changed

+13
-0
lines changed
  • src/main/java/io/github/marioluan/algorithms/sorting

1 file changed

+13
-0
lines changed

src/main/java/io/github/marioluan/algorithms/sorting/Sortable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ protected static boolean less(Comparable a, Comparable b) {
1919
return a.compareTo(b) < 0;
2020
}
2121

22+
/**
23+
* Check whether {@link Comparable a} is lesser or equal to
24+
* {@link Comparable b}.
25+
*
26+
* @param a
27+
* @param b
28+
* @return returns whether a is lesser or equal to b
29+
*/
30+
@SuppressWarnings({ "rawtypes", "unchecked" })
31+
protected static boolean lessOrEqual(Comparable a, Comparable b) {
32+
return a.compareTo(b) < 1;
33+
}
34+
2235
/**
2336
* Swap item in position i by item in position j from array {@link a}.
2437
*

0 commit comments

Comments
 (0)