本文整理匯總了Java中java.util.concurrent.PriorityBlockingQueue.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java PriorityBlockingQueue.toArray方法的具體用法?Java PriorityBlockingQueue.toArray怎麽用?Java PriorityBlockingQueue.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.PriorityBlockingQueue
的用法示例。
在下文中一共展示了PriorityBlockingQueue.toArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testToArray
import java.util.concurrent.PriorityBlockingQueue; //導入方法依賴的package包/類
/**
* toArray contains all elements
*/
public void testToArray() throws InterruptedException {
PriorityBlockingQueue q = populatedQueue(SIZE);
Object[] o = q.toArray();
Arrays.sort(o);
for (int i = 0; i < o.length; i++)
assertSame(o[i], q.take());
}
示例2: testToArray2
import java.util.concurrent.PriorityBlockingQueue; //導入方法依賴的package包/類
/**
* toArray(a) contains all elements
*/
public void testToArray2() throws InterruptedException {
PriorityBlockingQueue<Integer> q = populatedQueue(SIZE);
Integer[] ints = new Integer[SIZE];
Integer[] array = q.toArray(ints);
assertSame(ints, array);
Arrays.sort(ints);
for (int i = 0; i < ints.length; i++)
assertSame(ints[i], q.take());
}
示例3: testToArray1_BadArg
import java.util.concurrent.PriorityBlockingQueue; //導入方法依賴的package包/類
/**
* toArray(incompatible array type) throws ArrayStoreException
*/
public void testToArray1_BadArg() {
PriorityBlockingQueue q = populatedQueue(SIZE);
try {
q.toArray(new String[10]);
shouldThrow();
} catch (ArrayStoreException success) {}
}