38 |
|
private PriorityQueue<Integer> populatedQueue(int n) { |
39 |
|
PriorityQueue<Integer> q = new PriorityQueue<Integer>(n); |
40 |
|
assertTrue(q.isEmpty()); |
41 |
< |
for (int i = n-1; i >= 0; i -= 2) |
41 |
> |
for (int i = n - 1; i >= 0; i -= 2) |
42 |
|
assertTrue(q.offer(new Integer(i))); |
43 |
|
for (int i = (n & 1); i < n; i += 2) |
44 |
|
assertTrue(q.offer(new Integer(i))); |
191 |
|
PriorityQueue q = new PriorityQueue(1); |
192 |
|
try { |
193 |
|
q.offer(new Object()); |
194 |
– |
q.offer(new Object()); |
194 |
|
shouldThrow(); |
195 |
< |
} catch (ClassCastException success) {} |
195 |
> |
} catch (ClassCastException success) { |
196 |
> |
assertTrue(q.isEmpty()); |
197 |
> |
assertEquals(0, q.size()); |
198 |
> |
assertNull(q.poll()); |
199 |
> |
} |
200 |
|
} |
201 |
|
|
202 |
|
/** |
325 |
|
assertTrue(q.contains(i)); |
326 |
|
assertTrue(q.remove(i)); |
327 |
|
assertFalse(q.contains(i)); |
328 |
< |
assertTrue(q.contains(i-1)); |
328 |
> |
assertTrue(q.contains(i - 1)); |
329 |
|
} |
330 |
|
for (int i = 0; i < SIZE; i += 2) { |
331 |
|
assertTrue(q.contains(i)); |
332 |
|
assertTrue(q.remove(i)); |
333 |
|
assertFalse(q.contains(i)); |
334 |
< |
assertFalse(q.remove(i+1)); |
335 |
< |
assertFalse(q.contains(i+1)); |
334 |
> |
assertFalse(q.remove(i + 1)); |
335 |
> |
assertFalse(q.contains(i + 1)); |
336 |
|
} |
337 |
|
assertTrue(q.isEmpty()); |
338 |
|
} |