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()); |
335 |
|
|
336 |
|
Object e4 = q.lower(zero); |
337 |
|
assertNull(e4); |
342 |
– |
|
338 |
|
} |
339 |
|
|
340 |
|
/** |
353 |
|
|
354 |
|
Object e4 = q.higher(six); |
355 |
|
assertNull(e4); |
361 |
– |
|
356 |
|
} |
357 |
|
|
358 |
|
/** |
371 |
|
|
372 |
|
Object e4 = q.floor(zero); |
373 |
|
assertNull(e4); |
380 |
– |
|
374 |
|
} |
375 |
|
|
376 |
|
/** |
389 |
|
|
390 |
|
Object e4 = q.ceiling(six); |
391 |
|
assertNull(e4); |
399 |
– |
|
392 |
|
} |
393 |
|
|
394 |
|
/** |
456 |
|
it.remove(); |
457 |
|
|
458 |
|
it = q.iterator(); |
459 |
< |
assertEquals(it.next(), new Integer(2)); |
460 |
< |
assertEquals(it.next(), new Integer(3)); |
459 |
> |
assertEquals(it.next(), 2); |
460 |
> |
assertEquals(it.next(), 3); |
461 |
|
assertFalse(it.hasNext()); |
462 |
|
} |
463 |
|
|
713 |
|
public void testDescendingPoll() { |
714 |
|
NavigableSet q = populatedSet(SIZE); |
715 |
|
for (int i = 0; i < SIZE; ++i) { |
716 |
< |
assertEquals(i, ((Integer)q.pollFirst()).intValue()); |
716 |
> |
assertEquals(i, q.pollFirst()); |
717 |
|
} |
718 |
|
assertNull(q.pollFirst()); |
719 |
|
} |
753 |
|
q.clear(); |
754 |
|
assertTrue(q.isEmpty()); |
755 |
|
assertEquals(0, q.size()); |
756 |
< |
q.add(new Integer(1)); |
756 |
> |
assertTrue(q.add(new Integer(1))); |
757 |
|
assertFalse(q.isEmpty()); |
758 |
|
q.clear(); |
759 |
|
assertTrue(q.isEmpty()); |
826 |
|
|
827 |
|
Object e4 = q.lower(zero); |
828 |
|
assertNull(e4); |
837 |
– |
|
829 |
|
} |
830 |
|
|
831 |
|
/** |
844 |
|
|
845 |
|
Object e4 = q.higher(m6); |
846 |
|
assertNull(e4); |
856 |
– |
|
847 |
|
} |
848 |
|
|
849 |
|
/** |
862 |
|
|
863 |
|
Object e4 = q.floor(zero); |
864 |
|
assertNull(e4); |
875 |
– |
|
865 |
|
} |
866 |
|
|
867 |
|
/** |
880 |
|
|
881 |
|
Object e4 = q.ceiling(m6); |
882 |
|
assertNull(e4); |
894 |
– |
|
883 |
|
} |
884 |
|
|
885 |
|
/** |
947 |
|
it.remove(); |
948 |
|
|
949 |
|
it = q.iterator(); |
950 |
< |
assertEquals(it.next(), new Integer(2)); |
951 |
< |
assertEquals(it.next(), new Integer(3)); |
950 |
> |
assertEquals(it.next(), 2); |
951 |
> |
assertEquals(it.next(), 3); |
952 |
|
assertFalse(it.hasNext()); |
953 |
|
} |
954 |
|
|