64 |
|
PriorityBlockingQueue<Integer> q = |
65 |
|
new PriorityBlockingQueue<Integer>(n); |
66 |
|
assertTrue(q.isEmpty()); |
67 |
< |
for (int i = n-1; i >= 0; i-=2) |
67 |
> |
for (int i = n-1; i >= 0; i -= 2) |
68 |
|
assertTrue(q.offer(new Integer(i))); |
69 |
< |
for (int i = (n & 1); i < n; i+=2) |
69 |
> |
for (int i = (n & 1); i < n; i += 2) |
70 |
|
assertTrue(q.offer(new Integer(i))); |
71 |
|
assertFalse(q.isEmpty()); |
72 |
|
assertEquals(NOCAP, q.remainingCapacity()); |
266 |
|
public void testPut() { |
267 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
268 |
|
for (int i = 0; i < SIZE; ++i) { |
269 |
< |
Integer I = new Integer(i); |
270 |
< |
q.put(I); |
271 |
< |
assertTrue(q.contains(I)); |
269 |
> |
Integer x = new Integer(i); |
270 |
> |
q.put(x); |
271 |
> |
assertTrue(q.contains(x)); |
272 |
|
} |
273 |
|
assertEquals(SIZE, q.size()); |
274 |
|
} |
530 |
|
assertTrue(q.removeAll(p)); |
531 |
|
assertEquals(SIZE-i, q.size()); |
532 |
|
for (int j = 0; j < i; ++j) { |
533 |
< |
Integer I = (Integer)(p.remove()); |
534 |
< |
assertFalse(q.contains(I)); |
533 |
> |
Integer x = (Integer)(p.remove()); |
534 |
> |
assertFalse(q.contains(x)); |
535 |
|
} |
536 |
|
} |
537 |
|
} |
576 |
|
*/ |
577 |
|
public void testIterator() { |
578 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
579 |
– |
int i = 0; |
579 |
|
Iterator it = q.iterator(); |
580 |
< |
while (it.hasNext()) { |
580 |
> |
int i; |
581 |
> |
for (i = 0; it.hasNext(); i++) |
582 |
|
assertTrue(q.contains(it.next())); |
583 |
– |
++i; |
584 |
– |
} |
583 |
|
assertEquals(i, SIZE); |
584 |
+ |
assertIteratorExhausted(it); |
585 |
+ |
} |
586 |
+ |
|
587 |
+ |
/** |
588 |
+ |
* iterator of empty collection has no elements |
589 |
+ |
*/ |
590 |
+ |
public void testEmptyIterator() { |
591 |
+ |
assertIteratorExhausted(new PriorityBlockingQueue().iterator()); |
592 |
|
} |
593 |
|
|
594 |
|
/** |