From 6979f115f9a2f64d18cee4497f0dc2189266a17a Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 25 Apr 2018 00:10:00 +0200 Subject: Sort tests better in a few test suites. --- src/cz/crcs/ectester/data/EC_Store.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/cz/crcs/ectester/data/EC_Store.java') diff --git a/src/cz/crcs/ectester/data/EC_Store.java b/src/cz/crcs/ectester/data/EC_Store.java index e4ba40c..426dcd9 100644 --- a/src/cz/crcs/ectester/data/EC_Store.java +++ b/src/cz/crcs/ectester/data/EC_Store.java @@ -21,9 +21,7 @@ import javax.xml.validation.SchemaFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; /** * @author Jan Jancar johny@neuromancer.sk @@ -319,6 +317,21 @@ public class EC_Store { return getObject(objClass, query.substring(0, split), query.substring(split + 1)); } + public static List>> mapToCurve(Collection keys) { + Map> curves = new TreeMap<>(); + for (T key : keys) { + EC_Curve curve = EC_Store.getInstance().getObject(EC_Curve.class, key.getCurve()); + List curveKeys = curves.getOrDefault(curve, new LinkedList<>()); + curveKeys.add(key); + curves.putIfAbsent(curve, curveKeys); + } + List>> curveList = new LinkedList<>(); + curveList.addAll(curves.entrySet()); + Comparator>> c = Comparator.comparing(o -> o.getKey().getBits()); + curveList.sort(c.thenComparing(b -> b.getKey().getId())); + return curveList; + } + public static EC_Store getInstance() { if (instance == null) { instance = new EC_Store(); -- cgit v1.2.3-70-g09d2