public static T SelectRandom(T[] from) { float total = WeightedSet <T> .GetTotalWeight(from); int index = WeightedSet <T> .SelectRandomIndex(from, total); if (index == -1) { return(default(T)); } return(from[index]); }
public static int SelectRandomIndex(T[] from) { float total = WeightedSet <T> .GetTotalWeight(from); return(WeightedSet <T> .SelectRandomIndex(from, total)); }