@@ -0,0 +1,2768 @@
+package com.scottkillen.mod.koresample.common.util;%0A%0Aimport com.google.common.base.Objects;%0Aimport com.google.common.collect.HashMultiset;%0Aimport com.google.common.collect.Multiset;%0Aimport java.util.Collection;%0Aimport java.util.Iterator;%0Aimport java.util.Random;%0A%0Aimport static com.google.common.base.Preconditions.checkNotNull;%0A%0A@SuppressWarnings(%7B %22WeakerAccess%22, %22StandardVariableNames%22 %7D)%0Apublic class WeightedSet%3CT%3E  implements Collection%3CT%3E%0A%7B%0A    private final Random random;%0A    private final Multiset%3CT%3E elements = HashMultiset.create();%0A%0A    public WeightedSet()%0A    %7B%0A        this(new Random());%0A    %7D%0A%0A    public WeightedSet(Random random)%0A    %7B%0A        checkNotNull(random, %22Random generator is required.%22);%0A%0A        this.random = random;%0A    %7D%0A%0A    public T randomPick()%0A    %7B%0A        final int pick = random.nextInt(elements.size());%0A        int count = 0;%0A        for (final T t : elements.elementSet())%0A        %7B%0A            count += elements.count(t);%0A            if (count %3E= pick) return t;%0A        %7D%0A        //noinspection ReturnOfNull%0A        return null;%0A    %7D%0A%0A    public void setWeight(T t, int weight) %7B elements.setCount(t, weight); %7D%0A%0A    @Override%0A    public int size() %7B return elements.size(); %7D%0A%0A    @Override%0A    public boolean isEmpty() %7B return elements.isEmpty(); %7D%0A%0A    @Override%0A    public boolean contains(Object o) %7B return elements.contains(o); %7D%0A%0A    @Override%0A    public Iterator%3CT%3E iterator() %7B return elements.iterator(); %7D%0A%0A    @Override%0A    public Object%5B%5D toArray() %7B return elements.toArray(); %7D%0A%0A    @SuppressWarnings(%7B %22SuspiciousToArrayCall%22, %22TypeParameterHidesVisibleType%22 %7D)%0A    @Override%0A    public %3CT%3E T%5B%5D toArray(T%5B%5D a) %7B return elements.toArray(a); %7D%0A%0A    @Override%0A    public boolean add(T t) %7B return elements.add(t); %7D%0A%0A    @Override%0A    public boolean remove(Object o) %7B return elements.remove(o); %7D%0A%0A    @Override%0A    public boolean containsAll(Collection%3C?%3E c) %7B return elements.containsAll(c); %7D%0A%0A    @Override%0A    public boolean addAll(Collection%3C? extends T%3E c) %7B return elements.addAll(c); %7D%0A%0A    @Override%0A    public boolean removeAll(Collection%3C?%3E c) %7B return elements.removeAll(c); %7D%0A%0A    @Override%0A    public boolean retainAll(Collection%3C?%3E c) %7B return elements.retainAll(c); %7D%0A%0A    @Override%0A    public void clear() %7B elements.clear(); %7D%0A%0A    @Override%0A    public boolean equals(Object o)%0A    %7B%0A        if (!(o instanceof WeightedSet)) return false;%0A%0A        final WeightedSet%3C?%3E that = (WeightedSet%3C?%3E) o;%0A        return elements.equals(that.elements);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B return elements.hashCode(); %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return Objects.toStringHelper(this).add(%22random%22, random).add(%22elements%22, elements).toString();%0A    %7D%0A%7D%0A

Add WeightedSet utility.