From 07f7a1b9bc38fa6fa88961b2dc590e64db059c4e Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Sun, 12 May 2013 07:55:21 +0000 Subject: [PATCH] replaced boxed integers with plain ones. initial fill of arrays with zeros. --- .../java/forge/game/ai/ComputerUtilCard.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/forge/game/ai/ComputerUtilCard.java b/src/main/java/forge/game/ai/ComputerUtilCard.java index 4f27cc05d26..795ad057381 100644 --- a/src/main/java/forge/game/ai/ComputerUtilCard.java +++ b/src/main/java/forge/game/ai/ComputerUtilCard.java @@ -2,6 +2,7 @@ package forge.game.ai; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -826,7 +827,10 @@ public class ComputerUtilCard { public static List getColorByProminence(final List list) { int cntColors = MagicColor.WUBRG.length; - final Integer[] map = new Integer[cntColors]; + final int[] map = new int[cntColors]; + for(int i = 0; i < map.length; i++) { + map[i] = 0; + } for (final Card crd : list) { ColorSet color = CardUtil.getColors(crd); @@ -836,20 +840,20 @@ public class ComputerUtilCard { } } // for - Integer[] indices = new Integer[cntColors]; + int[] indices = new int[cntColors]; for(int i = 0; i < cntColors; i++) indices[i] = Integer.valueOf(i); - // sort indices for WUBRG array, to get indices for most prominent colors first. - Arrays.sort(indices, new Comparator() { - @Override public int compare(final Integer a, final Integer b) { return map[b] - map[a]; } - }); + // sort indices for WUBRG array + Arrays.sort(indices); // fetch color names in the same order List result = new ArrayList(cntColors); - for(Integer idx : indices) { + for(int idx : indices) { result.add(MagicColor.toLongString(MagicColor.WUBRG[idx])); } + // reverse to get indices for most prominent colors first. + Collections.reverse(result); return result; }