19 |
|
|
20 |
|
static class MyReverseComparator implements Comparator { |
21 |
|
public int compare(Object x, Object y) { |
22 |
< |
int i = ((Integer)x).intValue(); |
23 |
< |
int j = ((Integer)y).intValue(); |
24 |
< |
if (i < j) return 1; |
25 |
< |
if (i > j) return -1; |
26 |
< |
return 0; |
22 |
> |
return ((Comparable)y).compareTo(x); |
23 |
|
} |
24 |
|
} |
25 |
|
|
100 |
|
public void testEmpty() { |
101 |
|
NavigableSet q = set0(); |
102 |
|
assertTrue(q.isEmpty()); |
103 |
< |
q.add(new Integer(1)); |
103 |
> |
assertTrue(q.add(new Integer(1))); |
104 |
|
assertFalse(q.isEmpty()); |
105 |
< |
q.add(new Integer(2)); |
105 |
> |
assertTrue(q.add(new Integer(2))); |
106 |
|
q.pollFirst(); |
107 |
|
q.pollFirst(); |
108 |
|
assertTrue(q.isEmpty()); |
222 |
|
public void testPoll() { |
223 |
|
NavigableSet q = populatedSet(SIZE); |
224 |
|
for (int i = 0; i < SIZE; ++i) { |
225 |
< |
assertEquals(i, ((Integer)q.pollFirst()).intValue()); |
225 |
> |
assertEquals(i, q.pollFirst()); |
226 |
|
} |
227 |
|
assertNull(q.pollFirst()); |
228 |
|
} |
262 |
|
q.clear(); |
263 |
|
assertTrue(q.isEmpty()); |
264 |
|
assertEquals(0, q.size()); |
265 |
< |
q.add(new Integer(1)); |
265 |
> |
assertTrue(q.add(new Integer(1))); |
266 |
|
assertFalse(q.isEmpty()); |
267 |
|
q.clear(); |
268 |
|
assertTrue(q.isEmpty()); |
460 |
|
it.remove(); |
461 |
|
|
462 |
|
it = q.iterator(); |
463 |
< |
assertEquals(it.next(), new Integer(2)); |
464 |
< |
assertEquals(it.next(), new Integer(3)); |
463 |
> |
assertEquals(it.next(), 2); |
464 |
> |
assertEquals(it.next(), 3); |
465 |
|
assertFalse(it.hasNext()); |
466 |
|
} |
467 |
|
|
717 |
|
public void testDescendingPoll() { |
718 |
|
NavigableSet q = populatedSet(SIZE); |
719 |
|
for (int i = 0; i < SIZE; ++i) { |
720 |
< |
assertEquals(i, ((Integer)q.pollFirst()).intValue()); |
720 |
> |
assertEquals(i, q.pollFirst()); |
721 |
|
} |
722 |
|
assertNull(q.pollFirst()); |
723 |
|
} |
757 |
|
q.clear(); |
758 |
|
assertTrue(q.isEmpty()); |
759 |
|
assertEquals(0, q.size()); |
760 |
< |
q.add(new Integer(1)); |
760 |
> |
assertTrue(q.add(new Integer(1))); |
761 |
|
assertFalse(q.isEmpty()); |
762 |
|
q.clear(); |
763 |
|
assertTrue(q.isEmpty()); |
955 |
|
it.remove(); |
956 |
|
|
957 |
|
it = q.iterator(); |
958 |
< |
assertEquals(it.next(), new Integer(2)); |
959 |
< |
assertEquals(it.next(), new Integer(3)); |
958 |
> |
assertEquals(it.next(), 2); |
959 |
> |
assertEquals(it.next(), 3); |
960 |
|
assertFalse(it.hasNext()); |
961 |
|
} |
962 |
|
|