From 4d6d57786476cb7b3f712291334306996bae7921 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 27 Sep 2011 17:50:20 +0000 Subject: [PATCH] Some sensible tweaks to WeightedList suggested by MDB. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6706 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../java/com/threerings/util/WeightedList.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/threerings/util/WeightedList.java b/src/main/java/com/threerings/util/WeightedList.java index c2f92b312..62e7a41c7 100644 --- a/src/main/java/com/threerings/util/WeightedList.java +++ b/src/main/java/com/threerings/util/WeightedList.java @@ -39,31 +39,31 @@ public class WeightedList public static WeightedList newList (K... entry) { - return new WeightedList().add(entry); + return new WeightedList().addAll(entry); } public static WeightedList newList (Float weight, K entry) { - return new WeightedList().add(weight, entry); + return new WeightedList().addAll(weight, entry); } public static WeightedList newList (Float weight, K... entry) { - return new WeightedList().add(weight, entry); + return new WeightedList().addAll(weight, entry); } /** * Adds the given items with a weight of 1. */ - public WeightedList add (T... items) + public WeightedList addAll (T... items) { - return add(1f, items); + return addAll(1f, items); } /** * Adds the given item with the given weight. */ - public WeightedList add (float weight, T item) + public WeightedList addAll (float weight, T item) { _items.add(new Tuple(weight, item)); _weights = null; @@ -73,10 +73,10 @@ public class WeightedList /** * Adds all of the given items with the given weight. */ - public WeightedList add (float weight, T... items) + public WeightedList addAll (float weight, T... items) { for (T item : items) { - add(weight, item); + addAll(weight, item); } return this; } @@ -137,7 +137,7 @@ public class WeightedList @Override public String toString () { - return StringUtil.toString(_items); + return _items.toString(); } protected float[] _weights;