1package umontreal.ssj.latnetbuilder.weights;
3import java.util.ArrayList;
4import java.util.Collections;
18 protected ArrayList<SingletonWeightComparable<T>> weights;
19 boolean sorted =
false;
27 weights =
new ArrayList<SingletonWeightComparable<T>>(w);
34 weights =
new ArrayList<SingletonWeightComparable<T>>();
55 boolean added =
false;
57 if (w.getIndex() == singletonWeight.
getIndex() && (!added)) {
58 weights.set(weights.indexOf(w), singletonWeight);
63 weights.add(singletonWeight);
72 Collections.sort(weights);
83 public void add(T index,
double weight) {
Implements single instances of weights.
T getIndex()
Returns the current 'index'.
void add(T index, double weight)
Adds a new weight with index 'index' and weight 'weight' or overwrites it, if the index already exist...
WeightsComparable(List< SingletonWeightComparable< T > > w)
Constructs weights from a list of SingletonWeightsComparable.
WeightsComparable()
Initializes an empty list of comparable weights.
void sort()
Sorts the weights w.r.t.
ArrayList< SingletonWeightComparable< T > > getComparableWeights()
Returns the current comparable weights.
void add(SingletonWeightComparable< T > singletonWeight)
Adds a new comparable weight to the list.
Weights(List< SingletonWeight< T > > w)
Constructs weights from a list of SingletonWeights.