本文整理匯總了Java中java.util.concurrent.DelayQueue.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java DelayQueue.iterator方法的具體用法?Java DelayQueue.iterator怎麽用?Java DelayQueue.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.DelayQueue
的用法示例。
在下文中一共展示了DelayQueue.iterator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: realMain
import java.util.concurrent.DelayQueue; //導入方法依賴的package包/類
private static void realMain(String[] args) throws Throwable {
Godot[] godots = new Godot[] { new Godot(), new Godot(), new Godot() };
DelayQueue<Godot> q = new DelayQueue<>(Arrays.asList(godots));
Iterator<Godot> it = q.iterator();
q.clear();
check(it.hasNext());
equal(it.next(), godots[0]);
it.remove();
check(q.isEmpty());
q.addAll(Arrays.asList(godots));
it = q.iterator();
check(it.hasNext());
it.next();
equal(it.next(), godots[1]);
it.remove();
equal(q.size(), 2);
check(q.contains(godots[0]));
check(q.contains(godots[2]));
}
示例2: realMain
import java.util.concurrent.DelayQueue; //導入方法依賴的package包/類
private static void realMain(String[] args) throws Throwable {
Godot[] godots = new Godot[] { new Godot(), new Godot(), new Godot() };
DelayQueue<Godot> q = new DelayQueue<Godot>(Arrays.asList(godots));
Iterator<Godot> it = q.iterator();
q.clear();
check(it.hasNext());
equal(it.next(), godots[0]);
it.remove();
check(q.isEmpty());
q.addAll(Arrays.asList(godots));
it = q.iterator();
check(it.hasNext());
it.next();
equal(it.next(), godots[1]);
it.remove();
equal(q.size(), 2);
check(q.contains(godots[0]));
check(q.contains(godots[2]));
}
示例3: testIterator
import java.util.concurrent.DelayQueue; //導入方法依賴的package包/類
/**
* iterator iterates through all elements
*/
public void testIterator() {
DelayQueue q = populatedQueue(SIZE);
int i = 0;
Iterator it = q.iterator();
while (it.hasNext()) {
assertTrue(q.contains(it.next()));
++i;
}
assertEquals(i, SIZE);
assertIteratorExhausted(it);
}
示例4: testIteratorRemove
import java.util.concurrent.DelayQueue; //導入方法依賴的package包/類
/**
* iterator.remove removes current element
*/
public void testIteratorRemove() {
final DelayQueue q = new DelayQueue();
q.add(new PDelay(2));
q.add(new PDelay(1));
q.add(new PDelay(3));
Iterator it = q.iterator();
it.next();
it.remove();
it = q.iterator();
assertEquals(new PDelay(2), it.next());
assertEquals(new PDelay(3), it.next());
assertFalse(it.hasNext());
}