commit bbb15696ebf2259ae15fc4d94af372559e1a2b09 Author: Karsten Loesing karsten.loesing@gmx.net Date: Mon Aug 20 15:26:34 2018 +0200
Replace Collections.sort with List.sort. --- src/main/java/org/torproject/metrics/stats/advbwdist/Main.java | 6 ++---- src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java | 4 +--- src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java | 5 ++--- src/main/java/org/torproject/metrics/web/MetricServlet.java | 4 +--- src/main/java/org/torproject/metrics/web/NewsServlet.java | 4 +--- 5 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/torproject/metrics/stats/advbwdist/Main.java b/src/main/java/org/torproject/metrics/stats/advbwdist/Main.java index 6565961..a16e7b0 100644 --- a/src/main/java/org/torproject/metrics/stats/advbwdist/Main.java +++ b/src/main/java/org/torproject/metrics/stats/advbwdist/Main.java @@ -95,10 +95,8 @@ public class Main { }
/* Write advertised bandwidths of n-th fastest relays/exits. */ - Collections.sort(advertisedBandwidthsAllRelays, - Collections.reverseOrder()); - Collections.sort(advertisedBandwidthsExitsOnly, - Collections.reverseOrder()); + advertisedBandwidthsAllRelays.sort(Collections.reverseOrder()); + advertisedBandwidthsExitsOnly.sort(Collections.reverseOrder()); int[] fastestRelays = new int[] { 1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500, 1000, 2000, 3000, 5000 }; for (int fastestRelay : fastestRelays) { diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java index 2420485..9ef3ee8 100644 --- a/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java +++ b/src/main/java/org/torproject/metrics/stats/hidserv/Aggregator.java @@ -8,7 +8,6 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; @@ -124,8 +123,7 @@ public class Aggregator { /* Sort extrapolated network totals contained in the first array * element. (The second array element contains the computed * network fraction as weight.) */ - Collections.sort(weightedValues, - Comparator.comparingDouble(doubles -> doubles[0])); + weightedValues.sort(Comparator.comparingDouble(doubles -> doubles[0]));
/* For the weighted mean, sum up all previously extrapolated * values weighted with their network fractions (which happens to diff --git a/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java b/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java index 2c525d7..7acf1e8 100644 --- a/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java +++ b/src/main/java/org/torproject/metrics/stats/hidserv/Simulate.java @@ -171,8 +171,7 @@ public class Simulate { } } while (totalReportingProbability < fraction - 0.001 || totalReportingProbability > fraction + 0.001); - Collections.sort(singleRelayExtrapolations, - Comparator.comparingDouble(o -> o[0])); + singleRelayExtrapolations.sort(Comparator.comparingDouble(o -> o[0])); double totalProbability = 0.0; double totalValues = 0.0; double totalInterquartileProbability = 0.0; @@ -326,7 +325,7 @@ public class Simulate { } } while (totalReportingProbability < fraction - 0.001 || totalReportingProbability > fraction + 0.001); - Collections.sort(singleRelayExtrapolations, + singleRelayExtrapolations.sort( Comparator.comparingDouble(doubles -> doubles[0])); double totalProbability = 0.0; double totalValues = 0.0; diff --git a/src/main/java/org/torproject/metrics/web/MetricServlet.java b/src/main/java/org/torproject/metrics/web/MetricServlet.java index b3de046..3b279a9 100644 --- a/src/main/java/org/torproject/metrics/web/MetricServlet.java +++ b/src/main/java/org/torproject/metrics/web/MetricServlet.java @@ -5,7 +5,6 @@ package org.torproject.metrics.web;
import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -71,8 +70,7 @@ public abstract class MetricServlet extends AnyServlet { } } this.sortedEvents.addAll(ContentProvider.getInstance().getNewsList()); - Collections.sort(this.sortedEvents, - (o1, o2) -> o2.getStart().compareTo(o1.getStart())); + this.sortedEvents.sort((o1, o2) -> o2.getStart().compareTo(o1.getStart())); } }
diff --git a/src/main/java/org/torproject/metrics/web/NewsServlet.java b/src/main/java/org/torproject/metrics/web/NewsServlet.java index fc4d39f..f47f189 100644 --- a/src/main/java/org/torproject/metrics/web/NewsServlet.java +++ b/src/main/java/org/torproject/metrics/web/NewsServlet.java @@ -6,7 +6,6 @@ package org.torproject.metrics.web; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -36,8 +35,7 @@ public class NewsServlet extends AnyServlet { sortedNews.add(news); } } - Collections.sort(sortedNews, - (o1, o2) -> o1.getStart().compareTo(o2.getStart()) * -1); + sortedNews.sort((o1, o2) -> o1.getStart().compareTo(o2.getStart()) * -1); this.sortedNews = sortedNews; SortedMap<String, String> countries = new TreeMap<>(); for (String[] country : Countries.getInstance().getCountryList()) {
tor-commits@lists.torproject.org