1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
280 |
|
public void testRemoveElement() { |
281 |
|
TreeSet q = populatedSet(SIZE); |
282 |
|
for (int i = 1; i < SIZE; i+=2) { |
283 |
< |
assertTrue(q.remove(new Integer(i))); |
283 |
> |
assertTrue(q.contains(i)); |
284 |
> |
assertTrue(q.remove(i)); |
285 |
> |
assertFalse(q.contains(i)); |
286 |
> |
assertTrue(q.contains(i-1)); |
287 |
|
} |
288 |
|
for (int i = 0; i < SIZE; i+=2) { |
289 |
< |
assertTrue(q.remove(new Integer(i))); |
290 |
< |
assertFalse(q.remove(new Integer(i+1))); |
289 |
> |
assertTrue(q.contains(i)); |
290 |
> |
assertTrue(q.remove(i)); |
291 |
> |
assertFalse(q.contains(i)); |
292 |
> |
assertFalse(q.remove(i+1)); |
293 |
> |
assertFalse(q.contains(i+1)); |
294 |
|
} |
295 |
|
assertTrue(q.isEmpty()); |
296 |
|
} |
521 |
|
TreeSet q = populatedSet(SIZE); |
522 |
|
String s = q.toString(); |
523 |
|
for (int i = 0; i < SIZE; ++i) { |
524 |
< |
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
524 |
> |
assertTrue(s.contains(String.valueOf(i))); |
525 |
|
} |
526 |
|
} |
527 |
|
|
850 |
|
*/ |
851 |
|
void check(NavigableSet<Integer> set, |
852 |
|
final int min, final int max, final boolean ascending) { |
853 |
< |
class ReferenceSet { |
853 |
> |
class ReferenceSet { |
854 |
|
int lower(int element) { |
855 |
|
return ascending ? |
856 |
|
lowerAscending(element) : higherAscending(element); |