/** * @param operator "+" for filter in keeping positive values. "0" filter for keeping 0 values. "-" * for keeping negative values * @return */ public TreeSet<Interaction> getAllInteractions(String operator) { HashSet<Interaction> unsorted = new HashSet<>(); TreeSet<Interaction> out = new TreeSet<>(new ValueComparator()); Iterator<Interaction> iter = dsm.iterator(); while (iter.hasNext()) { Interaction interaction = iter.next(); double val = interaction.getValue(); if ((val == 0.0 && operator.equalsIgnoreCase("0")) || (val > 0.0 && operator.equalsIgnoreCase("+")) || (val < 0.0 && operator.equalsIgnoreCase("-"))) { unsorted.add(interaction); } } out.addAll(unsorted); return out; }
@Override public int compare(Interaction o1, Interaction o2) { return (int) (o1.getValue() - o2.getValue()); }