/** * Constructs discrete weighted value with specified <code>values</code> and <code>weights</code>. * * @param countValuePairs List of values with their corresponding weights. */ public ExactWeightedValue(List<CountValuePair<T>> countValuePairs) { if (countValuePairs == null || countValuePairs.isEmpty()) { throw new IllegalArgumentException("List of count value pairs cannot be null nor empty."); } this.distribution = new UniformDistribution(); this.counts = new ArrayList<>(); this.currentNumberOfValues = new ArrayList<>(); this.values = new ArrayList<>(); this.currentTotalCount = 0; for (CountValuePair<T> pair : countValuePairs) { currentTotalCount += pair.getCount(); counts.add(pair.getCount()); currentNumberOfValues.add(0L); values.add(pair.getValue()); } this.totalCount = currentTotalCount; }
/** * Constructs discrete weighted value with specified <code>values</code> and <code>weights</code>. * * @param countValuePairs List of values with their corresponding weights. */ public ExactWeightedValue(List<CountValuePair<T>> countValuePairs) { if (countValuePairs == null || countValuePairs.isEmpty()) { throw new IllegalArgumentException("List of count value pairs cannot be null nor empty."); } this.distribution = new UniformDistribution(); this.counts = new ArrayList<>(); this.currentNumberOfValues = new ArrayList<>(); this.values = new ArrayList<>(); this.currentTotalCount = 0; for (CountValuePair<T> pair : countValuePairs) { currentTotalCount += pair.getCount(); counts.add(pair.getCount()); currentNumberOfValues.add(0L); values.add(pair.getValue()); } this.totalCount = currentTotalCount; }