Java Code Examples for java.util.concurrent.PriorityBlockingQueue#iterator()
The following examples show how to use
java.util.concurrent.PriorityBlockingQueue#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PriorityBlockingQueueTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * iterator.remove removes current element */ public void testIteratorRemove() { final PriorityBlockingQueue q = new PriorityBlockingQueue(3); q.add(new Integer(2)); q.add(new Integer(1)); q.add(new Integer(3)); Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); assertEquals(it.next(), new Integer(2)); assertEquals(it.next(), new Integer(3)); assertFalse(it.hasNext()); }
Example 2
Source File: PriorityBlockingQueueTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * iterator.remove removes current element */ public void testIteratorRemove() { final PriorityBlockingQueue q = new PriorityBlockingQueue(3); q.add(new Integer(2)); q.add(new Integer(1)); q.add(new Integer(3)); Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); assertEquals(it.next(), new Integer(2)); assertEquals(it.next(), new Integer(3)); assertFalse(it.hasNext()); }
Example 3
Source File: PriorityBlockingQueueTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * iterator iterates through all elements */ public void testIterator() { PriorityBlockingQueue q = populatedQueue(SIZE); Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); assertEquals(i, SIZE); assertIteratorExhausted(it); }
Example 4
Source File: PriorityBlockingQueueTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * iterator iterates through all elements */ public void testIterator() { PriorityBlockingQueue q = populatedQueue(SIZE); Iterator it = q.iterator(); int i; for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next())); assertEquals(i, SIZE); assertIteratorExhausted(it); }
Example 5
Source File: SharedMergeScheduler.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
private void remove(PriorityBlockingQueue<MergeWork> queue, String id) { Iterator<MergeWork> iterator = queue.iterator(); while (iterator.hasNext()) { MergeWork mergeWork = iterator.next(); if (id.equals(mergeWork.getId())) { iterator.remove(); } } }