36 |
|
private PriorityQueue populatedQueue(int n) { |
37 |
|
PriorityQueue q = new PriorityQueue(n); |
38 |
|
assertTrue(q.isEmpty()); |
39 |
< |
for(int i = n-1; i >= 0; i-=2) |
39 |
> |
for (int i = n-1; i >= 0; i-=2) |
40 |
|
assertTrue(q.offer(new Integer(i))); |
41 |
< |
for(int i = (n & 1); i < n; i+=2) |
41 |
> |
for (int i = (n & 1); i < n; i+=2) |
42 |
|
assertTrue(q.offer(new Integer(i))); |
43 |
|
assertFalse(q.isEmpty()); |
44 |
|
assertEquals(n, q.size()); |
204 |
|
q.offer(new Object()); |
205 |
|
shouldThrow(); |
206 |
|
} |
207 |
< |
catch(ClassCastException success) {} |
207 |
> |
catch (ClassCastException success) {} |
208 |
|
} |
209 |
|
|
210 |
|
/** |
428 |
|
PriorityQueue q = populatedQueue(SIZE); |
429 |
|
Object[] o = q.toArray(); |
430 |
|
Arrays.sort(o); |
431 |
< |
for(int i = 0; i < o.length; i++) |
431 |
> |
for (int i = 0; i < o.length; i++) |
432 |
|
assertEquals(o[i], q.poll()); |
433 |
|
} |
434 |
|
|
440 |
|
Integer[] ints = new Integer[SIZE]; |
441 |
|
ints = (Integer[])q.toArray(ints); |
442 |
|
Arrays.sort(ints); |
443 |
< |
for(int i = 0; i < ints.length; i++) |
443 |
> |
for (int i = 0; i < ints.length; i++) |
444 |
|
assertEquals(ints[i], q.poll()); |
445 |
|
} |
446 |
|
|
451 |
|
PriorityQueue q = populatedQueue(SIZE); |
452 |
|
int i = 0; |
453 |
|
Iterator it = q.iterator(); |
454 |
< |
while(it.hasNext()) { |
454 |
> |
while (it.hasNext()) { |
455 |
|
assertTrue(q.contains(it.next())); |
456 |
|
++i; |
457 |
|
} |
506 |
|
assertEquals(q.size(), r.size()); |
507 |
|
while (!q.isEmpty()) |
508 |
|
assertEquals(q.remove(), r.remove()); |
509 |
< |
} catch(Exception e){ |
509 |
> |
} catch (Exception e){ |
510 |
|
unexpectedException(); |
511 |
|
} |
512 |
|
} |