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

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(216)

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

Deque.remove介绍

[英]Retrieves and removes the head of the queue represented by this deque (in other words, the first element of 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().
[中]检索并删除此deque表示的队列头(换句话说,此deque的第一个元素)。此方法与#poll的不同之处在于,如果此deque为空,则会引发异常。
此方法相当于#removeFirst()。

代码示例

代码示例来源:origin: square/okhttp

  1. /**
  2. * Notify this pool that {@code connection} has become idle. Returns true if the connection has
  3. * been removed from the pool and should be closed.
  4. */
  5. boolean connectionBecameIdle(RealConnection connection) {
  6. assert (Thread.holdsLock(this));
  7. if (connection.noNewStreams || maxIdleConnections == 0) {
  8. connections.remove(connection);
  9. return true;
  10. } else {
  11. notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit.
  12. return false;
  13. }
  14. }

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

  1. create().peek();
  2. create().poll();
  3. create().remove();
  4. create().add("foo");
  5. create().addAll(ImmutableList.of("foo"));
  6. create().isEmpty();
  7. create().iterator();
  8. create().remove("foo");
  9. create().removeAll(ImmutableList.of("foo"));
  10. create().retainAll(ImmutableList.of("foo"));

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

  1. private void evictConnection(Holder holder) {
  2. holder.removed = true;
  3. connectionRemoved.accept(holder.connection);
  4. if (holder.capacity > 0) {
  5. capacity -= holder.capacity;
  6. available.remove(holder);
  7. holder.capacity = 0;
  8. }
  9. weight -= holder.weight;
  10. }

代码示例来源:origin: square/okhttp

  1. private <T> void finished(Deque<T> calls, T call) {
  2. Runnable idleCallback;
  3. synchronized (this) {
  4. if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  5. idleCallback = this.idleCallback;
  6. }
  7. boolean isRunning = promoteAndExecute();
  8. if (!isRunning && idleCallback != null) {
  9. idleCallback.run();
  10. }
  11. }

代码示例来源:origin: prestodb/presto

  1. /**
  2. * Notify this pool that {@code connection} has become idle. Returns true if the connection has
  3. * been removed from the pool and should be closed.
  4. */
  5. boolean connectionBecameIdle(RealConnection connection) {
  6. assert (Thread.holdsLock(this));
  7. if (connection.noNewStreams || maxIdleConnections == 0) {
  8. connections.remove(connection);
  9. return true;
  10. } else {
  11. notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit.
  12. return false;
  13. }
  14. }

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

  1. private void deletePartition(long pid) {
  2. LOG.debug("Delete partition: {}", pid);
  3. try {
  4. partitionIdsLock.lock();
  5. partitionIds.remove(pid);
  6. partitionIdsState.put(PARTITION_IDS_KEY, partitionIds);
  7. } finally {
  8. partitionIdsLock.unlock();
  9. }
  10. }

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

  1. @Override
  2. public E remove() {
  3. assertTrue(Thread.holdsLock(mutex));
  4. return delegate.remove();
  5. }

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

  1. @Override
  2. public boolean remove(Object object) {
  3. assertTrue(Thread.holdsLock(mutex));
  4. return delegate.remove(object);
  5. }

代码示例来源:origin: com.squareup.okhttp3/okhttp

  1. private <T> void finished(Deque<T> calls, T call) {
  2. Runnable idleCallback;
  3. synchronized (this) {
  4. if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  5. idleCallback = this.idleCallback;
  6. }
  7. boolean isRunning = promoteAndExecute();
  8. if (!isRunning && idleCallback != null) {
  9. idleCallback.run();
  10. }
  11. }

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

  1. /** {@inheritDoc} */
  2. @Override public E remove() {
  3. E res = deque.remove();
  4. adder.decrement();
  5. return res;
  6. }

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

  1. /** {@inheritDoc} */
  2. @Override public boolean remove(Object o) {
  3. boolean res = deque.remove(o);
  4. if (res)
  5. adder.decrement();
  6. return res;
  7. }

代码示例来源:origin: prestodb/presto

  1. private <T> void finished(Deque<T> calls, T call, boolean promoteCalls) {
  2. int runningCallsCount;
  3. Runnable idleCallback;
  4. synchronized (this) {
  5. if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  6. if (promoteCalls) promoteCalls();
  7. runningCallsCount = runningCallsCount();
  8. idleCallback = this.idleCallback;
  9. }
  10. if (runningCallsCount == 0 && idleCallback != null) {
  11. idleCallback.run();
  12. }
  13. }

代码示例来源:origin: MovingBlocks/Terasology

  1. @Override
  2. public void closeScreen(UIScreenLayer screen) {
  3. if (screens.remove(screen)) {
  4. ResourceUrn screenUri = screenLookup.inverse().remove(screen);
  5. onCloseScreen(screen, screenUri, true);
  6. }
  7. }

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

  1. private static void removeTillMatching(Deque<Term> terms, String begin, String end) {
  2. assert terms.peek().is(begin);
  3. terms.remove();
  4. for (;;) {
  5. if (terms.peek().is(begin)) {
  6. removeTillMatching(terms, begin, end);
  7. } else if (terms.remove().is(end)) {
  8. return;
  9. }
  10. }
  11. }

代码示例来源:origin: square/okhttp

  1. connections.remove(longestIdleConnection);
  2. } else if (idleConnectionCount > 0) {

代码示例来源:origin: bytedeco/javacpp

  1. /** Removes the Pointer from the {@link #pointerStack} of this Scope. */
  2. public PointerScope detach(Pointer p) {
  3. if (logger.isDebugEnabled()) {
  4. logger.debug("Detaching " + p + " from " + this);
  5. }
  6. pointerStack.remove(p);
  7. return this;
  8. }

代码示例来源:origin: MovingBlocks/Terasology

  1. private void closeScreen(ResourceUrn screenUri, boolean sendEvents) {
  2. UIScreenLayer screen = screenLookup.remove(screenUri);
  3. if (screen != null) {
  4. screens.remove(screen);
  5. onCloseScreen(screen, screenUri, sendEvents);
  6. }
  7. }

代码示例来源:origin: bytedeco/javacpp

  1. /** Calls {@link #deallocate()} when {@link #deallocateOnClose} is true,
  2. * and removes itself from {@link #scopeStack}. */
  3. @Override public void close() {
  4. if (logger.isDebugEnabled()) {
  5. logger.debug("Closing " + this);
  6. }
  7. if (deallocateOnClose()) {
  8. deallocate();
  9. }
  10. scopeStack.get().remove(this);
  11. }

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

  1. /**
  2. * Abort all incomplete batches (whether they have been sent or not)
  3. */
  4. void abortBatches(final RuntimeException reason) {
  5. for (ProducerBatch batch : incomplete.copyAll()) {
  6. Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
  7. synchronized (dq) {
  8. batch.abortRecordAppends();
  9. dq.remove(batch);
  10. }
  11. batch.abort(reason);
  12. deallocate(batch);
  13. }
  14. }

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

  1. /**
  2. * Abort any batches which have not been drained
  3. */
  4. void abortUndrainedBatches(RuntimeException reason) {
  5. for (ProducerBatch batch : incomplete.copyAll()) {
  6. Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
  7. boolean aborted = false;
  8. synchronized (dq) {
  9. if ((transactionManager != null && !batch.hasSequence()) || (transactionManager == null && !batch.isClosed())) {
  10. aborted = true;
  11. batch.abortRecordAppends();
  12. dq.remove(batch);
  13. }
  14. }
  15. if (aborted) {
  16. batch.abort(reason);
  17. deallocate(batch);
  18. }
  19. }
  20. }

相关文章