List of usage examples for java.util TreeSet comparator
public Comparator<? super E> comparator()
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> tree = new TreeSet<Integer>(Collections.reverseOrder()); tree.add(12);/*from w w w .j av a 2 s . c om*/ tree.add(13); tree.add(14); tree.add(15); tree.add(16); tree.add(17); // using comparator System.out.println(tree.comparator()); }
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
/** * Test method for 'java.util.TreeSet.TreeSet(Comparator)'. * * @see java.util.TreeSet#TreeSet(Comparator) *//* w ww . j ava 2 s . co m*/ public void testConstructor_comparator() { TreeSet<E> TreeSet = new TreeSet<E>(getComparator()); _assertEmpty(TreeSet); if (isNaturalOrder()) { assertNull(TreeSet.comparator()); } else { assertSame(getComparator(), TreeSet.comparator()); } }
From source file:org.jamocha.dn.ConflictSet.java
private TreeSet<RuleAndToken> correctStrategy(final Integer salience, final TreeSet<RuleAndToken> ratSet) { if (this.conflictResolutionStrategy == ratSet.comparator()) return ratSet; // if wrong comparator was used, create new set and copy the values final TreeSet<RuleAndToken> newRatSet = new TreeSet<>(this.conflictResolutionStrategy); newRatSet.addAll(ratSet);/*from www . j a v a 2s . c o m*/ this.rulesAndTokensBySalience.put(salience, newRatSet); return newRatSet; }