From fae5ad96f11bfd1d3571ffbeb58db645e7734bed Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Tue, 4 Aug 2020 18:54:11 -0300 Subject: Perform some basic ways of grouping outputted affixes --- src/main/java/tlIItools/AffixSet.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/main/java/tlIItools/AffixSet.java') diff --git a/src/main/java/tlIItools/AffixSet.java b/src/main/java/tlIItools/AffixSet.java index 569649ec..d7f14211 100644 --- a/src/main/java/tlIItools/AffixSet.java +++ b/src/main/java/tlIItools/AffixSet.java @@ -1,15 +1,23 @@ package tlIItools; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; + /** * Container of a set of affixes. * * @author Ben Culkin */ public class AffixSet { + private static class AffixComparator implements Comparator { + public int compare(Affix a1, Affix a2) { + if (a1.minLevel == a2.minLevel) { + return a1.maxLevel - a2.maxLevel; + } + + return a1.minLevel - a2.minLevel; + } + } + /** * All of the affix groups contained in this set. * @@ -27,9 +35,9 @@ public class AffixSet { * Create a new blank affix set. */ public AffixSet() { - affixGroups = new HashMap<>(); + affixGroups = new TreeMap<>(); - ungroupedAffixes = new HashSet<>(); + ungroupedAffixes = new TreeSet<>(new AffixComparator()); } /** -- cgit v1.2.3