private void colorOverlappingBranches(LinkedBlockingQueue<SPTNode> queue) { HashMap<Vertex,Integer> stateHeight = new HashMap<Vertex,Integer>(); Iterator<SPTNode> nodes = queue.iterator(); while(nodes.hasNext()){ SPTNode node = nodes.next(); Integer height = stateHeight.get(node.state.getVertex()); if(height==null){ height = 0; } else{ height += 1; } stateHeight.put(node.state.getVertex(),height); node.setHeight(height); } }
/** * iterator of empty collection has no elements */ public void testEmptyIterator() { assertIteratorExhausted(new LinkedBlockingQueue().iterator()); }
/** * Modifications do not cause iterators to fail */ public void testWeaklyConsistentIteration() { final LinkedBlockingQueue q = new LinkedBlockingQueue(3); q.add(one); q.add(two); q.add(three); for (Iterator it = q.iterator(); it.hasNext();) { q.remove(); it.next(); } assertEquals(0, q.size()); }
/** * iterator.remove removes current element */ public void testIteratorRemove() { final LinkedBlockingQueue q = new LinkedBlockingQueue(3); q.add(two); q.add(one); q.add(three); Iterator it = q.iterator(); it.next(); it.remove(); it = q.iterator(); assertSame(it.next(), one); assertSame(it.next(), three); assertFalse(it.hasNext()); }
/** * iterator ordering is FIFO */ public void testIteratorOrdering() { final LinkedBlockingQueue q = new LinkedBlockingQueue(3); q.add(one); q.add(two); q.add(three); assertEquals(0, q.remainingCapacity()); int k = 0; for (Iterator it = q.iterator(); it.hasNext();) { assertEquals(++k, it.next()); } assertEquals(3, k); }
/** * iterator iterates through all elements */ public void testIterator() throws InterruptedException { LinkedBlockingQueue 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); it = q.iterator(); for (i = 0; it.hasNext(); i++) assertEquals(it.next(), q.take()); assertEquals(i, SIZE); assertIteratorExhausted(it); }
private void retryDownedHosts() { Iterator<CassandraHost> iter = downedHostQueue.iterator(); while (iter.hasNext()) { CassandraHost host = iter.next(); if (host == null) { continue; } boolean reconnected = verifyConnection(host); if (reconnected) { ((CassandraClientFactory) clientFactory).addCassandraHost(host); iter.remove(); } } } }
Iterator<Object> iterator = restoredTaskHarness.getOutput().iterator(); while (iterator.hasNext()) { if (iterator.next() instanceof CheckpointBarrier) {
Iterator<CassandraHost> iter = downedHostQueue.iterator(); while( iter.hasNext() ) { CassandraHost cassandraHost = iter.next();
/** * This iterator actually allows creating multiple iterators unlike the * default {@link #iterator()} of this class. */ public Iterator<Object> reusableIterator() { return super.iterator(); }
/** * This iterator actually allows creating multiple iterators unlike the * default {@link #iterator()} of this class. */ public Iterator<Object> reusableIterator() { return super.iterator(); }
public Iterator<T> iterator() { return delegate.iterator(); } }
/** * This iterator actually allows creating multiple iterators unlike the * default {@link #iterator()} of this class. */ public Iterator<Object> reusableIterator() { return super.iterator(); }
@Override public Iterator<E> iterator() { return queue.iterator(); }
@Override public Iterator<E> iterator() { return queue.iterator(); }
private void harvestObsolete() { Iterator<Observable> iterator = queue.iterator(); while (iterator.hasNext()) { Observable observable = iterator.next(); if (observable.isObsolete()) { iterator.remove(); } } }
@Override public Iterator<E> iterator() { return new Itr(super.iterator()); }
public void cancelReconnectGroup(final String group) { this.canceledGroupSet.add(group); final Iterator<ReconnectTask> it = this.tasks.iterator(); while (it.hasNext()) { final ReconnectTask task = it.next(); if (task.getGroupSet().contains(group)) { log.warn("Invalid reconnect request,it is removed,the group set is:" + task.getGroupSet()); it.remove(); } } }
public void cancelReconnectGroup(final String group) { this.canceledGroupSet.add(group); final Iterator<ReconnectTask> it = this.tasks.iterator(); while (it.hasNext()) { final ReconnectTask task = it.next(); if (task.getGroupSet().contains(group)) { log.warn("Invalid reconnect request,it is removed,the group set is:" + task.getGroupSet()); it.remove(); } } }
public void notifyInteractionUpdated(boolean successful) { checkConversationQueue(); ApptentiveNotificationCenter.defaultCenter() .postNotification(NOTIFICATION_INTERACTIONS_DID_FETCH, NOTIFICATION_KEY_SUCCESSFUL, successful); Iterator it = interactionUpdateListeners.iterator(); while (it.hasNext()) { InteractionManager.InteractionUpdateListener listener = (InteractionManager.InteractionUpdateListener) it.next(); if (listener != null) { listener.onInteractionUpdated(successful); } } }