summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matthias Jaros <jarlucmat@mailbox.org>2026-07-04 14:20:23 +0200
committerGravatar Matthias Jaros <jarlucmat@mailbox.org>2026-07-09 09:59:28 +0200
commitab186911c77342fab37a3364c4191d5c0fe5daa7 (patch)
tree0c1cc4b96013957e6797861469ba6e6f30dadcd6
parent23da4efb64952bbe372719a9cf107489de408de4 (diff)
Improved algorithm by sorting first and then removing all that are 100%
and break once we reach one that does not have that
-rw-r--r--src/main/java/com/it_jaros/jscanner/ProgressBar.java7
1 files 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<Progress> 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);
}