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))); |
89 |
|
*/ |
90 |
|
public void testConstructor5() { |
91 |
|
Integer[] ints = new Integer[SIZE]; |
92 |
< |
for (int i = 0; i < SIZE-1; ++i) |
92 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
93 |
|
ints[i] = new Integer(i); |
94 |
|
try { |
95 |
|
new PriorityQueue(Arrays.asList(ints)); |
120 |
|
for (int i = 0; i < SIZE; ++i) |
121 |
|
ints[i] = new Integer(i); |
122 |
|
q.addAll(Arrays.asList(ints)); |
123 |
< |
for (int i = SIZE-1; i >= 0; --i) |
123 |
> |
for (int i = SIZE - 1; i >= 0; --i) |
124 |
|
assertEquals(ints[i], q.poll()); |
125 |
|
} |
126 |
|
|
144 |
|
public void testSize() { |
145 |
|
PriorityQueue q = populatedQueue(SIZE); |
146 |
|
for (int i = 0; i < SIZE; ++i) { |
147 |
< |
assertEquals(SIZE-i, q.size()); |
147 |
> |
assertEquals(SIZE - i, q.size()); |
148 |
|
q.remove(); |
149 |
|
} |
150 |
|
for (int i = 0; i < SIZE; ++i) { |
236 |
|
public void testAddAll3() { |
237 |
|
PriorityQueue q = new PriorityQueue(SIZE); |
238 |
|
Integer[] ints = new Integer[SIZE]; |
239 |
< |
for (int i = 0; i < SIZE-1; ++i) |
239 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
240 |
|
ints[i] = new Integer(i); |
241 |
|
try { |
242 |
|
q.addAll(Arrays.asList(ints)); |
251 |
|
Integer[] empty = new Integer[0]; |
252 |
|
Integer[] ints = new Integer[SIZE]; |
253 |
|
for (int i = 0; i < SIZE; ++i) |
254 |
< |
ints[i] = new Integer(SIZE-1-i); |
254 |
> |
ints[i] = new Integer(SIZE - 1 - i); |
255 |
|
PriorityQueue q = new PriorityQueue(SIZE); |
256 |
|
assertFalse(q.addAll(Arrays.asList(empty))); |
257 |
|
assertTrue(q.addAll(Arrays.asList(ints))); |
322 |
|
assertTrue(q.contains(i)); |
323 |
|
assertTrue(q.remove(i)); |
324 |
|
assertFalse(q.contains(i)); |
325 |
< |
assertTrue(q.contains(i-1)); |
325 |
> |
assertTrue(q.contains(i - 1)); |
326 |
|
} |
327 |
|
for (int i = 0; i < SIZE; i += 2) { |
328 |
|
assertTrue(q.contains(i)); |
329 |
|
assertTrue(q.remove(i)); |
330 |
|
assertFalse(q.contains(i)); |
331 |
< |
assertFalse(q.remove(i+1)); |
332 |
< |
assertFalse(q.contains(i+1)); |
331 |
> |
assertFalse(q.remove(i + 1)); |
332 |
> |
assertFalse(q.contains(i + 1)); |
333 |
|
} |
334 |
|
assertTrue(q.isEmpty()); |
335 |
|
} |
388 |
|
assertTrue(changed); |
389 |
|
|
390 |
|
assertTrue(q.containsAll(p)); |
391 |
< |
assertEquals(SIZE-i, q.size()); |
391 |
> |
assertEquals(SIZE - i, q.size()); |
392 |
|
p.remove(); |
393 |
|
} |
394 |
|
} |
401 |
|
PriorityQueue q = populatedQueue(SIZE); |
402 |
|
PriorityQueue p = populatedQueue(i); |
403 |
|
assertTrue(q.removeAll(p)); |
404 |
< |
assertEquals(SIZE-i, q.size()); |
404 |
> |
assertEquals(SIZE - i, q.size()); |
405 |
|
for (int j = 0; j < i; ++j) { |
406 |
|
Integer x = (Integer)(p.remove()); |
407 |
|
assertFalse(q.contains(x)); |