You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/10/29 11:57:26 UTC

[commons-rng] 02/04: Results command to list test application names in encountered order.

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit 35c11f7bc95faf40a3470479058ed21293ca5787
Author: aherbert <ah...@apache.org>
AuthorDate: Tue Oct 29 11:25:10 2019 +0000

    Results command to list test application names in encountered order.
---
 .../apache/commons/rng/examples/stress/ResultsCommand.java    | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
index c05a51e..85ec4c5 100644
--- a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
+++ b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
@@ -39,9 +39,11 @@ import java.util.Formatter;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.function.Function;
 import java.util.function.Supplier;
@@ -1086,19 +1088,18 @@ class ResultsCommand implements Callable<Void> {
     }
 
     /**
-     * Gets the test names present in the results.
+     * Gets the test names present in the results. These are returned in encountered order.
      *
      * @param results Results.
      * @return the test names
      */
     private static List<String> getTestNames(List<TestResult> results) {
-        final HashSet<String> set = new HashSet<>();
+        // Enforce encountered order with a linked hash set.
+        final Set<String> set = new LinkedHashSet<>();
         for (final TestResult result : results) {
             set.add(result.getTestApplicationName());
         }
-        final ArrayList<String> list = new ArrayList<>(set);
-        Collections.sort(list);
-        return list;
+        return new ArrayList<>(set);
     }
 
     /**