make unionUnsorted 5-10% faster for lists with 100k elements
This commit is contained in:
@@ -1062,14 +1062,14 @@ public final class IntList implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IntList unionUnsorted(final IntList a, final IntList b) {
|
private static IntList unionUnsorted(final IntList a, final IntList b) {
|
||||||
// TODO use a more efficient algorithm. Especially the removeIf is too
|
// TODO use a more efficient algorithm. The sort operations make this 10 times
|
||||||
// expensive, because of all the method calls
|
// slower than unionSorted
|
||||||
final IntList result;
|
|
||||||
result = new IntList(a.size() + b.size());
|
final IntList aSorted = new IntList(a);
|
||||||
result.addAll(a);
|
aSorted.parallelSort();
|
||||||
result.addAll(b);
|
final IntList bSorted = new IntList(b);
|
||||||
result.sort();
|
bSorted.parallelSort();
|
||||||
result.removeIf((value, index) -> index > 0 && result.get(index) == result.get(index - 1));
|
|
||||||
return result;
|
return unionSorted(aSorted, bSorted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user