java.util.ArrayDeque.remove()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中java.util.ArrayDeque.remove()方法的一些代码示例,展示了ArrayDeque.remove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.remove()方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:remove

ArrayDeque.remove介绍

[英]Retrieves and removes the head of the queue represented by this deque. This method differs from #poll only in that it throws an exception if this deque is empty.

This method is equivalent to #removeFirst.
[中]检索并删除此数据块表示的队列头。此方法与#poll的不同之处在于,如果此deque为空,则会引发异常。
此方法相当于#removeFirst。

代码示例

代码示例来源:origin: prolificinteractive/material-calendarview

@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
 V pagerView = (V) object;
 currentViews.remove(pagerView);
 container.removeView(pagerView);
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
void handleClose() {
 if (pendingPushes.remove(this)) {
  completionHandler.fail("Push reset by client");
 } else {
  concurrentStreams--;
  while ((maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) && pendingPushes.size() > 0) {
   Push push = pendingPushes.pop();
   concurrentStreams++;
   context.runOnContext(v -> {
    push.complete();
   });
  }
  response.handleClose();
 }
}

代码示例来源:origin: google/ExoPlayer

private long applySpeedup(long positionUs) {
 @Nullable PlaybackParametersCheckpoint checkpoint = null;
 while (!playbackParametersCheckpoints.isEmpty()
   && positionUs >= playbackParametersCheckpoints.getFirst().positionUs) {
  checkpoint = playbackParametersCheckpoints.remove();
 }
 if (checkpoint != null) {
  // We are playing (or about to play) media with the new playback parameters, so update them.
  playbackParameters = checkpoint.playbackParameters;
  playbackParametersPositionUs = checkpoint.positionUs;
  playbackParametersOffsetUs = checkpoint.mediaTimeUs - startMediaTimeUs;
 }
 if (playbackParameters.speed == 1f) {
  return positionUs + playbackParametersOffsetUs - playbackParametersPositionUs;
 }
 if (playbackParametersCheckpoints.isEmpty()) {
  return playbackParametersOffsetUs
    + audioProcessorChain.getMediaDuration(positionUs - playbackParametersPositionUs);
 }
 // We are playing data at a previous playback speed, so fall back to multiplying by the speed.
 return playbackParametersOffsetUs
   + Util.getMediaDurationForPlayoutDuration(
     positionUs - playbackParametersPositionUs, playbackParameters.speed);
}

代码示例来源:origin: eclipse-vertx/vert.x

protected void updateSettings(Http2Settings settingsUpdate, Handler<AsyncResult<Void>> completionHandler) {
 Http2Settings current = handler.decoder().localSettings();
 for (Map.Entry<Character, Long> entry : current.entrySet()) {
  Character key = entry.getKey();
  if (Objects.equals(settingsUpdate.get(key), entry.getValue())) {
   settingsUpdate.remove(key);
  }
 }
 Handler<Void> pending = v -> {
  synchronized (Http2ConnectionBase.this) {
   localSettings.putAll(settingsUpdate);
  }
  if (completionHandler != null) {
   completionHandler.handle(Future.succeededFuture());
  }
 };
 updateSettingsHandlers.add(pending);
 handler.writeSettings(settingsUpdate).addListener(fut -> {
  if (!fut.isSuccess()) {
   synchronized (Http2ConnectionBase.this) {
    updateSettingsHandlers.remove(pending);
   }
   if (completionHandler != null) {
    completionHandler.handle(Future.failedFuture(fut.cause()));
   }
  }
 });
}

代码示例来源:origin: apache/kafka

@Override
protected Record makeNext() {
  if (innerEntries.isEmpty())
    return allDone();
  AbstractLegacyRecordBatch entry = innerEntries.remove();
  // Convert offset to absolute offset if needed.
  if (wrapperMagic == RecordBatch.MAGIC_VALUE_V1) {
    long absoluteOffset = absoluteBaseOffset + entry.offset();
    entry = new BasicLegacyRecordBatch(absoluteOffset, entry.outerRecord());
  }
  if (entry.isCompressed())
    throw new InvalidRecordException("Inner messages must not be compressed");
  return entry;
}

代码示例来源:origin: com.h2database/h2

} finally {
  session.setWaitForLock(null, null);
  waitingSessions.remove(session);

代码示例来源:origin: requery/requery

private ArrayList<Type<?>> sortTypes() {
  // sort the types in table creation order to avoid referencing not created table via a
  // reference (could also add constraints at the end but SQLite doesn't support that)
  ArrayDeque<Type<?>> queue = new ArrayDeque<>(model.getTypes());
  ArrayList<Type<?>> sorted = new ArrayList<>();
  while (!queue.isEmpty()) {
    Type<?> type = queue.poll();
    if (type.isView()) {
      continue;
    }
    Set<Type<?>> referencing = referencedTypesOf(type);
    for (Type<?> referenced : referencing) {
      Set<Type<?>> backReferences = referencedTypesOf(referenced);
      if (backReferences.contains(type)) {
        throw new CircularReferenceException("circular reference detected between "
          + type.getName() + " and " + referenced.getName());
      }
    }
    if (referencing.isEmpty() || sorted.containsAll(referencing)) {
      sorted.add(type);
      queue.remove(type);
    } else {
      queue.offer(type); // put back
    }
  }
  return sorted;
}

代码示例来源:origin: com.h2database/h2

WAITING_FOR_LOCK.remove();
waitingSessions.remove(session);

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public T remove() {
  return queue.remove();
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public boolean remove(Object o) {
  return queue.remove(o);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Add the given element to the queue, possibly forcing an eviction from the head if {@link #remainingCapacity()} is
 * zero.
 *
 * @param t the element to add
 * @return true if the element was added (always the case for {@code EvictingQueue}
 */
@Override
public boolean add(T t) {
  if (maximumSize == 0) {
    return true;
  }
  if (queue.size() == maximumSize) {
    queue.remove();
  }
  queue.add(t);
  return true;
}

代码示例来源:origin: magefree/mage

/**
 * 
 * performs a breadth first search for a matching game state
 * 
 * @param state - the game state that we are looking for
 * @return the matching state or null if no match is found
 */
public MCTSNode getMatchingState(String state) {
  ArrayDeque<MCTSNode> queue = new ArrayDeque<>();
  queue.add(this);
  while (!queue.isEmpty()) {
    MCTSNode current = queue.remove();
    if (current.stateValue.equals(state))
      return current;
    for (MCTSNode child: current.children) {
      queue.add(child);
    }
  }
  return null;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

private void nextPath() {
 Path p = paths.remove();
 loader = new _SingleLoader(p, sourceIndex, blockSize);
 sourceIndex++;
 currentPath = p;
 iterator = loader.iterator();
}

代码示例来源:origin: io.vertx/vertx-core

@Override
void handleClose() {
 if (pendingPushes.remove(this)) {
  completionHandler.fail("Push reset by client");
 } else {
  concurrentStreams--;
  while ((maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) && pendingPushes.size() > 0) {
   Push push = pendingPushes.pop();
   concurrentStreams++;
   context.runOnContext(v -> {
    push.complete();
   });
  }
  response.handleClose();
 }
}

代码示例来源:origin: io.vertx/vertx-core

protected void updateSettings(Http2Settings settingsUpdate, Handler<AsyncResult<Void>> completionHandler) {
 Http2Settings current = handler.decoder().localSettings();
 for (Map.Entry<Character, Long> entry : current.entrySet()) {
  Character key = entry.getKey();
  if (Objects.equals(settingsUpdate.get(key), entry.getValue())) {
   settingsUpdate.remove(key);
  }
 }
 Handler<Void> pending = v -> {
  synchronized (Http2ConnectionBase.this) {
   localSettings.putAll(settingsUpdate);
  }
  if (completionHandler != null) {
   completionHandler.handle(Future.succeededFuture());
  }
 };
 updateSettingsHandlers.add(pending);
 handler.writeSettings(settingsUpdate).addListener(fut -> {
  if (!fut.isSuccess()) {
   synchronized (Http2ConnectionBase.this) {
    updateSettingsHandlers.remove(pending);
   }
   if (completionHandler != null) {
    completionHandler.handle(Future.failedFuture(fut.cause()));
   }
  }
 });
}

代码示例来源:origin: magefree/mage

public boolean remove(StackObject object, Game game) {
  for (StackObject spell : this) {
    if (spell.getId().equals(object.getId())) {
      game.getState().setZone(spell.getId(), null);
      return super.remove(spell);
    }
  }
  return false;
}

代码示例来源:origin: akarnokd/RxJava2Extensions

void remove(SfmInnerSubscriber<T, R> inner) {
  synchronized (this) {
    active.remove(inner);
    version++;
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public boolean remove(Object o)
{
  return frames.remove(o);
}

代码示例来源:origin: org.apache.flink/flink-runtime

@Override
MemorySegment requestSegmentFromPool(Object owner) {
  ByteBuffer buf = availableMemory.remove();
  return MemorySegmentFactory.wrapPooledOffHeapMemory(buf, owner);
}

代码示例来源:origin: freenet/fred

public void removeRequest(SendableGet request, boolean persistent, ClientContext context, short prio) {
  if(logMINOR) Logger.minor(this, "Removing request prio="+prio+" persistent="+persistent);
  QueueItem requestMatcher = new QueueItem(null, request, null);
  synchronized(this) {
    if(!queue[prio].remove(requestMatcher)) return;
  }
  if(logMINOR) Logger.minor(this, "Removed transient request");
}

相关文章