Code example for TreeSet

Methods: addfirstisEmptylast

0
	/** 
	 * @tests java.util.TreeSet#TreeSet(java.util.Comparator) 
	 */ 
	public void test_ConstructorLjava_util_Comparator() { 
		// Test for method java.util.TreeSet(java.util.Comparator) 
		TreeSet myTreeSet = new TreeSet(new ReversedIntegerComparator());
		assertTrue("Did not construct correct TreeSet", myTreeSet.isEmpty());
		myTreeSet.add(new Integer(1));
		myTreeSet.add(new Integer(2));
		assertTrue(
				"Answered incorrect first element--did not use custom comparator ", 
				myTreeSet.first().equals(new Integer(2)));
		assertTrue(
				"Answered incorrect last element--did not use custom comparator ", 
				myTreeSet.last().equals(new Integer(1)));
	} 
 
	/** 
	 * @tests java.util.TreeSet#TreeSet(java.util.SortedSet) 
	 */ 
Contextual code suggestions in your IDE  Get Codota for Java