本文整理了Java中java.util.Deque.iterator()
方法的一些代码示例,展示了Deque.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Deque.iterator()
方法的具体详情如下:
包路径:java.util.Deque
类名称:Deque
方法名:iterator
[英]Returns an iterator over the elements in this deque in proper sequence. The elements will be returned in order from first (head) to last (tail).
[中]按正确的顺序返回此数据块中元素的迭代器。元素将按从第一个(头部)到最后一个(尾部)的顺序返回。
代码示例来源:origin: alibaba/jstorm
@Override
public void put(K key, V value) {
Iterator<Map<K, V>> it = buckets.iterator();
Map<K, V> bucket = it.next();
bucket.put(key, value);
while (it.hasNext()) {
bucket = it.next();
bucket.remove(key);
}
}
代码示例来源:origin: facebook/litho
builder.append('\n');
boolean isLast;
final Iterator<InternalNode> iterator = stack.iterator();
iterator.next();
iterator.next();
for (int index = 0; index < level - 1; index++) {
isLast = iterator.next() == null;
if (!isLast) {
while (iterator.next() != null) ;
代码示例来源:origin: square/okhttp
/** Close and remove all idle connections in the pool. */
public void evictAll() {
List<RealConnection> evictedConnections = new ArrayList<>();
synchronized (this) {
for (Iterator<RealConnection> i = connections.iterator(); i.hasNext(); ) {
RealConnection connection = i.next();
if (connection.allocations.isEmpty()) {
connection.noNewStreams = true;
evictedConnections.add(connection);
i.remove();
}
}
}
for (RealConnection connection : evictedConnections) {
closeQuietly(connection.socket());
}
}
代码示例来源:origin: apache/ignite
/**
* @param ses Session.
*/
public void resend(GridNioSession ses) {
assert ses instanceof GridSelectorNioSessionImpl;
GridNioRecoveryDescriptor recoveryDesc = ses.outRecoveryDescriptor();
if (recoveryDesc != null && !recoveryDesc.messagesRequests().isEmpty()) {
Deque<SessionWriteRequest> futs = recoveryDesc.messagesRequests();
if (log.isDebugEnabled())
log.debug("Resend messages [rmtNode=" + recoveryDesc.node().id() + ", msgCnt=" + futs.size() + ']');
GridSelectorNioSessionImpl ses0 = (GridSelectorNioSessionImpl)ses;
SessionWriteRequest fut0 = futs.iterator().next();
for (SessionWriteRequest fut : futs) {
fut.messageThread(true);
fut.resetSession(ses0);
}
ses0.resend(futs);
// Wake up worker.
ses0.offerStateChange((GridNioServer.SessionChangeRequest)fut0);
}
}
代码示例来源:origin: MovingBlocks/Terasology
private void purge() {
if (chunks.size() == 0) {
return;
}
final Iterator<WeakReference<Chunk>> it = chunks.iterator();
while (it.hasNext()) {
final WeakReference<Chunk> w = it.next();
if (w.get() == null) {
it.remove();
}
}
}
代码示例来源:origin: org.jpmml/pmml-model
default
public PMMLObject getParent(int index){
Deque<PMMLObject> parents = getParents();
if(index < 0){
throw new IllegalArgumentException();
}
Iterator<PMMLObject> it = parents.iterator();
for(int i = 0; i < index; i++){
it.next();
}
return it.next();
}
代码示例来源:origin: prestodb/presto
private void promoteCalls() {
if (runningAsyncCalls.size() >= maxRequests) return; // Already running max capacity.
if (readyAsyncCalls.isEmpty()) return; // No ready calls to promote.
for (Iterator<AsyncCall> i = readyAsyncCalls.iterator(); i.hasNext(); ) {
AsyncCall call = i.next();
if (runningCallsForHost(call) < maxRequestsPerHost) {
i.remove();
runningAsyncCalls.add(call);
executorService().execute(call);
}
if (runningAsyncCalls.size() >= maxRequests) return; // Reached max capacity.
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public T parent() {
Iterator<PathAwareVisitor.PathElement<T>> iterator = deque.iterator();
if (iterator.hasNext()) {
iterator.next();
if (iterator.hasNext()) {
return iterator.next().getElement();
}
}
throw new NoSuchElementException("Path is either empty or has only one element. There is no parent");
}
代码示例来源:origin: prestodb/presto
/** Close and remove all idle connections in the pool. */
public void evictAll() {
List<RealConnection> evictedConnections = new ArrayList<>();
synchronized (this) {
for (Iterator<RealConnection> i = connections.iterator(); i.hasNext(); ) {
RealConnection connection = i.next();
if (connection.allocations.isEmpty()) {
connection.noNewStreams = true;
evictedConnections.add(connection);
i.remove();
}
}
}
for (RealConnection connection : evictedConnections) {
closeQuietly(connection.socket());
}
}
代码示例来源:origin: apache/flink
/**
* Acknowledges the session ids.
* @param checkpointId The id of the current checkout to acknowledge ids for.
* @param uniqueIds The checkpointed unique ids which are ignored here. They only serve as a
* means of de-duplicating messages when the acknowledgment after a checkpoint
* fails.
*/
@Override
protected final void acknowledgeIDs(long checkpointId, Set<UId> uniqueIds) {
LOG.debug("Acknowledging ids for checkpoint {}", checkpointId);
Iterator<Tuple2<Long, List<SessionId>>> iterator = sessionIdsPerSnapshot.iterator();
while (iterator.hasNext()) {
final Tuple2<Long, List<SessionId>> next = iterator.next();
long id = next.f0;
if (id <= checkpointId) {
acknowledgeSessionIDs(next.f1);
// remove ids for this session
iterator.remove();
}
}
}
代码示例来源:origin: square/okhttp
/**
* Promotes eligible calls from {@link #readyAsyncCalls} to {@link #runningAsyncCalls} and runs
* them on the executor service. Must not be called with synchronization because executing calls
* can call into user code.
*
* @return true if the dispatcher is currently running calls.
*/
private boolean promoteAndExecute() {
assert (!Thread.holdsLock(this));
List<AsyncCall> executableCalls = new ArrayList<>();
boolean isRunning;
synchronized (this) {
for (Iterator<AsyncCall> i = readyAsyncCalls.iterator(); i.hasNext(); ) {
AsyncCall asyncCall = i.next();
if (runningAsyncCalls.size() >= maxRequests) break; // Max capacity.
if (runningCallsForHost(asyncCall) >= maxRequestsPerHost) continue; // Host max capacity.
i.remove();
executableCalls.add(asyncCall);
runningAsyncCalls.add(asyncCall);
}
isRunning = runningCallsCount() > 0;
}
for (int i = 0, size = executableCalls.size(); i < size; i++) {
AsyncCall asyncCall = executableCalls.get(i);
asyncCall.executeOn(executorService());
}
return isRunning;
}
代码示例来源:origin: io.dropwizard.metrics/metrics-core
synchronized String out() {
final StringBuilder builder = new StringBuilder();
final Iterator<Chunk> iterator = chunks.iterator();
while (iterator.hasNext()) {
final Chunk chunk = iterator.next();
builder.append('[');
for (int i = chunk.startIndex; i < chunk.cursor; i++) {
builder.append('(').append(chunk.keys[i]).append(": ")
.append(chunk.values[i]).append(')').append(' ');
}
builder.append(']');
if (iterator.hasNext()) {
builder.append("->");
}
}
return builder.toString();
}
代码示例来源:origin: immutables/immutables
private static void removeCommentsAndWhitespace(Deque<Term> terms) {
Iterator<Term> it = terms.iterator();
while (it.hasNext()) {
Term n = it.next();
if (n.isComment() || n.isWhitespace()) {
it.remove();
}
}
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/** Close and remove all idle connections in the pool. */
public void evictAll() {
List<RealConnection> evictedConnections = new ArrayList<>();
synchronized (this) {
for (Iterator<RealConnection> i = connections.iterator(); i.hasNext(); ) {
RealConnection connection = i.next();
if (connection.allocations.isEmpty()) {
connection.noNewStreams = true;
evictedConnections.add(connection);
i.remove();
}
}
}
for (RealConnection connection : evictedConnections) {
closeQuietly(connection.socket());
}
}
代码示例来源:origin: ehcache/ehcache3
@Override
public void reset() {
Iterator<FireableStoreEventHolder<K, V>> iterator = events.iterator();
while (iterator.hasNext()) {
FireableStoreEventHolder<K, V> next = iterator.next();
if (ordered) {
BlockingQueue<FireableStoreEventHolder<K, V>> orderedQueue = getOrderedQueue(next);
orderedQueue.remove(next);
fireWaiters(listeners, orderedQueue);
}
iterator.remove();
}
}
代码示例来源:origin: elastic/elasticsearch-hadoop
@Override
public String getProperty(String name) {
String value = writeSettings.getProperty(name);
if (value == null) {
Iterator<Settings> toCheck = settingsList.iterator();
while (value == null && toCheck.hasNext()) {
Settings next = toCheck.next();
value = next.getProperty(name);
}
}
return value;
}
代码示例来源:origin: square/okhttp
for (Iterator<Certificate> i = queue.iterator(); i.hasNext(); ) {
X509Certificate signingCert = (X509Certificate) i.next();
if (verifySignature(toVerify, signingCert)) {
i.remove();
代码示例来源:origin: square/okhttp
for (Iterator<RealConnection> i = connections.iterator(); i.hasNext(); ) {
RealConnection connection = i.next();
代码示例来源:origin: kiegroup/optaplanner
protected void adjustTabuList(int tabuStepIndex, Collection<? extends Object> tabus) {
int totalTabuListSize = workingTabuSize + workingFadingTabuSize; // is at least 1
// Remove the oldest tabu(s)
for (Iterator<Object> it = tabuSequenceDeque.iterator(); it.hasNext();) {
Object oldTabu = it.next();
Integer oldTabuStepIndexInteger = tabuToStepIndexMap.get(oldTabu);
if (oldTabuStepIndexInteger == null) {
throw new IllegalStateException("HashCode stability violation: the hashCode() of tabu ("
+ oldTabu + ") of class (" + oldTabu.getClass()
+ ") changed during planning, since it was inserted in the tabu Map or Set.");
}
int oldTabuStepCount = tabuStepIndex - oldTabuStepIndexInteger; // at least 1
if (oldTabuStepCount < totalTabuListSize) {
break;
}
it.remove();
tabuToStepIndexMap.remove(oldTabu);
}
// Add the new tabu(s)
for (Object tabu : tabus) {
// Push tabu to the end of the line
if (tabuToStepIndexMap.containsKey(tabu)) {
tabuToStepIndexMap.remove(tabu);
tabuSequenceDeque.remove(tabu);
}
tabuToStepIndexMap.put(tabu, tabuStepIndex);
tabuSequenceDeque.add(tabu);
}
}
代码示例来源:origin: btraceio/btrace
protected List<StackItem> getMethodParams(String desc, boolean isStatic) {
Type[] argTypes = Type.getArgumentTypes(desc);
int idx = argTypes.length - 1;
List<StackItem> items = new ArrayList<>();
Iterator<StackItem> it = state.fState.stack.iterator();
while (it.hasNext() && idx >= 0) {
Type t = argTypes[idx];
items.add(0, it.next());
if (t.equals(Type.LONG_TYPE) || t.equals(Type.DOUBLE_TYPE)) {
it.next();
}
idx--;
}
if (!isStatic && it.hasNext()) {
items.add(0, it.next());
}
return items;
}
}
内容来源于网络,如有侵权,请联系作者删除!