當前位置: 首頁>>代碼示例>>Java>>正文


Java DelayQueue.iterator方法代碼示例

本文整理匯總了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]));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:Iterate.java

示例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]));
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:21,代碼來源:Iterate.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:DelayQueueTest.java

示例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());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:DelayQueueTest.java


注:本文中的java.util.concurrent.DelayQueue.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。