From ab186911c77342fab37a3364c4191d5c0fe5daa7 Mon Sep 17 00:00:00 2001 From: Matthias Jaros Date: Sat, 4 Jul 2026 14:20:23 +0200 Subject: Improved algorithm by sorting first and then removing all that are 100% and break once we reach one that does not have that --- src/main/java/com/it_jaros/jscanner/ProgressBar.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/it_jaros/jscanner/ProgressBar.java b/src/main/java/com/it_jaros/jscanner/ProgressBar.java index 7c73057..12a359c 100644 --- a/src/main/java/com/it_jaros/jscanner/ProgressBar.java +++ b/src/main/java/com/it_jaros/jscanner/ProgressBar.java @@ -61,17 +61,20 @@ public class ProgressBar { } private void drawProgress(boolean last) { + // sort -> the more progressed the host the more up it is + hosts.sort(Comparator.comparingInt((Progress p) -> p.done().get()).reversed()); + // find and print finished hosts one last time for (Iterator it = hosts.iterator(); it.hasNext(); ) { Progress p = it.next(); if (p.done().get() == p.total()) { it.remove(); drawBar(p); + } else { + break; } } - // the more progressed the host the more up it is - hosts.sort(Comparator.comparingInt((Progress p) -> p.done().get()).reversed()); for (Progress progress : hosts) { drawBar(progress); } -- cgit v1.3.1