100 |
|
* Queue contains all elements of collection used to initialize |
101 |
|
*/ |
102 |
|
public void testConstructor6() { |
103 |
< |
try { |
104 |
< |
Integer[] ints = new Integer[SIZE]; |
105 |
< |
for (int i = 0; i < SIZE; ++i) |
106 |
< |
ints[i] = new Integer(i); |
107 |
< |
PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); |
108 |
< |
for (int i = 0; i < SIZE; ++i) |
109 |
< |
assertEquals(ints[i], q.poll()); |
110 |
< |
} |
111 |
< |
finally {} |
103 |
> |
Integer[] ints = new Integer[SIZE]; |
104 |
> |
for (int i = 0; i < SIZE; ++i) |
105 |
> |
ints[i] = new Integer(i); |
106 |
> |
PriorityQueue q = new PriorityQueue(Arrays.asList(ints)); |
107 |
> |
for (int i = 0; i < SIZE; ++i) |
108 |
> |
assertEquals(ints[i], q.poll()); |
109 |
|
} |
110 |
|
|
111 |
|
/** |
112 |
|
* The comparator used in constructor is used |
113 |
|
*/ |
114 |
|
public void testConstructor7() { |
115 |
< |
try { |
116 |
< |
MyReverseComparator cmp = new MyReverseComparator(); |
117 |
< |
PriorityQueue q = new PriorityQueue(SIZE, cmp); |
118 |
< |
assertEquals(cmp, q.comparator()); |
119 |
< |
Integer[] ints = new Integer[SIZE]; |
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) |
127 |
< |
assertEquals(ints[i], q.poll()); |
128 |
< |
} |
129 |
< |
finally {} |
115 |
> |
MyReverseComparator cmp = new MyReverseComparator(); |
116 |
> |
PriorityQueue q = new PriorityQueue(SIZE, cmp); |
117 |
> |
assertEquals(cmp, q.comparator()); |
118 |
> |
Integer[] ints = new Integer[SIZE]; |
119 |
> |
for (int i = 0; i < SIZE; ++i) |
120 |
> |
ints[i] = new Integer(i); |
121 |
> |
q.addAll(Arrays.asList(ints)); |
122 |
> |
for (int i = SIZE-1; i >= 0; --i) |
123 |
> |
assertEquals(ints[i], q.poll()); |
124 |
|
} |
125 |
|
|
126 |
|
/** |
247 |
|
* Queue contains all elements of successful addAll |
248 |
|
*/ |
249 |
|
public void testAddAll5() { |
250 |
< |
try { |
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); |
255 |
< |
PriorityQueue q = new PriorityQueue(SIZE); |
256 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
257 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
258 |
< |
for (int i = 0; i < SIZE; ++i) |
265 |
< |
assertEquals(new Integer(i), q.poll()); |
266 |
< |
} |
267 |
< |
finally {} |
250 |
> |
Integer[] empty = new Integer[0]; |
251 |
> |
Integer[] ints = new Integer[SIZE]; |
252 |
> |
for (int i = 0; i < SIZE; ++i) |
253 |
> |
ints[i] = new Integer(SIZE-1-i); |
254 |
> |
PriorityQueue q = new PriorityQueue(SIZE); |
255 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
256 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
257 |
> |
for (int i = 0; i < SIZE; ++i) |
258 |
> |
assertEquals(new Integer(i), q.poll()); |
259 |
|
} |
260 |
|
|
261 |
|
/** |