62 |
|
PriorityBlockingQueue<Integer> q = |
63 |
|
new PriorityBlockingQueue<Integer>(n); |
64 |
|
assertTrue(q.isEmpty()); |
65 |
< |
for (int i = n-1; i >= 0; i -= 2) |
65 |
> |
for (int i = n - 1; i >= 0; i -= 2) |
66 |
|
assertTrue(q.offer(new Integer(i))); |
67 |
|
for (int i = (n & 1); i < n; i += 2) |
68 |
|
assertTrue(q.offer(new Integer(i))); |
116 |
|
*/ |
117 |
|
public void testConstructor5() { |
118 |
|
Integer[] ints = new Integer[SIZE]; |
119 |
< |
for (int i = 0; i < SIZE-1; ++i) |
119 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
120 |
|
ints[i] = i; |
121 |
|
Collection<Integer> elements = Arrays.asList(ints); |
122 |
|
try { |
148 |
|
for (int i = 0; i < SIZE; ++i) |
149 |
|
ints[i] = new Integer(i); |
150 |
|
q.addAll(Arrays.asList(ints)); |
151 |
< |
for (int i = SIZE-1; i >= 0; --i) |
151 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
152 |
|
assertEquals(ints[i], q.poll()); |
153 |
|
} |
154 |
|
|
234 |
|
public void testAddAll3() { |
235 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
236 |
|
Integer[] ints = new Integer[SIZE]; |
237 |
< |
for (int i = 0; i < SIZE-1; ++i) |
237 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
238 |
|
ints[i] = new Integer(i); |
239 |
|
try { |
240 |
|
q.addAll(Arrays.asList(ints)); |
248 |
|
public void testAddAll5() { |
249 |
|
Integer[] empty = new Integer[0]; |
250 |
|
Integer[] ints = new Integer[SIZE]; |
251 |
< |
for (int i = SIZE-1; i >= 0; --i) |
251 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
252 |
|
ints[i] = new Integer(i); |
253 |
|
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE); |
254 |
|
assertFalse(q.addAll(Arrays.asList(empty))); |
512 |
|
assertTrue(changed); |
513 |
|
|
514 |
|
assertTrue(q.containsAll(p)); |
515 |
< |
assertEquals(SIZE-i, q.size()); |
515 |
> |
assertEquals(SIZE - i, q.size()); |
516 |
|
p.remove(); |
517 |
|
} |
518 |
|
} |
525 |
|
PriorityBlockingQueue q = populatedQueue(SIZE); |
526 |
|
PriorityBlockingQueue p = populatedQueue(i); |
527 |
|
assertTrue(q.removeAll(p)); |
528 |
< |
assertEquals(SIZE-i, q.size()); |
528 |
> |
assertEquals(SIZE - i, q.size()); |
529 |
|
for (int j = 0; j < i; ++j) { |
530 |
|
Integer x = (Integer)(p.remove()); |
531 |
|
assertFalse(q.contains(x)); |
689 |
|
final PriorityBlockingQueue q = populatedQueue(SIZE); |
690 |
|
Thread t = new Thread(new CheckedRunnable() { |
691 |
|
public void realRun() { |
692 |
< |
q.put(new Integer(SIZE+1)); |
692 |
> |
q.put(new Integer(SIZE + 1)); |
693 |
|
}}); |
694 |
|
|
695 |
|
t.start(); |
706 |
|
* drainTo(c, n) empties first min(n, size) elements of queue into c |
707 |
|
*/ |
708 |
|
public void testDrainToN() { |
709 |
< |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2); |
709 |
> |
PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE * 2); |
710 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
711 |
|
for (int j = 0; j < SIZE; j++) |
712 |
|
assertTrue(q.offer(new Integer(j))); |
714 |
|
q.drainTo(l, i); |
715 |
|
int k = (i < SIZE) ? i : SIZE; |
716 |
|
assertEquals(k, l.size()); |
717 |
< |
assertEquals(SIZE-k, q.size()); |
717 |
> |
assertEquals(SIZE - k, q.size()); |
718 |
|
for (int j = 0; j < k; ++j) |
719 |
|
assertEquals(l.get(j), new Integer(j)); |
720 |
|
do {} while (q.poll() != null); |