Refactor RxJava (#2749)

* Refactor RxJava

* Merge fix
This commit is contained in:
Grzegorz Piwowarek
2017-10-18 17:13:04 +02:00
committed by GitHub
parent e5400faad8
commit f753a86e84
15 changed files with 41 additions and 45 deletions
@@ -4,22 +4,20 @@ import java.util.stream.IntStream;
public class BubbleSort {
public void bubbleSort(Integer[] arr) {
void bubbleSort(Integer[] arr) {
int n = arr.length;
IntStream.range(0, n - 1)
.forEach(i -> {
IntStream.range(i + 1, n - i)
.forEach(j -> {
if (arr[j - 1] > arr[j]) {
int temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
}
});
});
.flatMap(i -> IntStream.range(i + 1, n - i))
.forEach(j -> {
if (arr[j - 1] > arr[j]) {
int temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
}
});
}
public void optimizedBubbleSort(Integer[] arr) {
void optimizedBubbleSort(Integer[] arr) {
int i = 0, n = arr.length;
boolean swapNeeded = true;
while (i < n - 1 && swapNeeded) {
@@ -37,5 +35,4 @@ public class BubbleSort {
i++;
}
}
}