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

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

本文整理了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

/**
 * Notify this pool that {@code connection} has become idle. Returns true if the connection has
 * been removed from the pool and should be closed.
 */
boolean connectionBecameIdle(RealConnection connection) {
 assert (Thread.holdsLock(this));
 if (connection.noNewStreams || maxIdleConnections == 0) {
  connections.remove(connection);
  return true;
 } else {
  notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit.
  return false;
 }
}

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

create().peek();
create().poll();
create().remove();
create().add("foo");
create().addAll(ImmutableList.of("foo"));
create().isEmpty();
create().iterator();
create().remove("foo");
create().removeAll(ImmutableList.of("foo"));
create().retainAll(ImmutableList.of("foo"));

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

private void evictConnection(Holder holder) {
 holder.removed = true;
 connectionRemoved.accept(holder.connection);
 if (holder.capacity > 0) {
  capacity -= holder.capacity;
  available.remove(holder);
  holder.capacity = 0;
 }
 weight -= holder.weight;
}

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

private <T> void finished(Deque<T> calls, T call) {
 Runnable idleCallback;
 synchronized (this) {
  if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  idleCallback = this.idleCallback;
 }
 boolean isRunning = promoteAndExecute();
 if (!isRunning && idleCallback != null) {
  idleCallback.run();
 }
}

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

/**
 * Notify this pool that {@code connection} has become idle. Returns true if the connection has
 * been removed from the pool and should be closed.
 */
boolean connectionBecameIdle(RealConnection connection) {
 assert (Thread.holdsLock(this));
 if (connection.noNewStreams || maxIdleConnections == 0) {
  connections.remove(connection);
  return true;
 } else {
  notifyAll(); // Awake the cleanup thread: we may have exceeded the idle connection limit.
  return false;
 }
}

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

private void deletePartition(long pid) {
  LOG.debug("Delete partition: {}", pid);
  try {
    partitionIdsLock.lock();
    partitionIds.remove(pid);
    partitionIdsState.put(PARTITION_IDS_KEY, partitionIds);
  } finally {
    partitionIdsLock.unlock();
  }
}

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

@Override
public E remove() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.remove();
}

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

@Override
public boolean remove(Object object) {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.remove(object);
}

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

private <T> void finished(Deque<T> calls, T call) {
 Runnable idleCallback;
 synchronized (this) {
  if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  idleCallback = this.idleCallback;
 }
 boolean isRunning = promoteAndExecute();
 if (!isRunning && idleCallback != null) {
  idleCallback.run();
 }
}

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

/** {@inheritDoc} */
@Override public E remove() {
  E res = deque.remove();
  adder.decrement();
  return res;
}

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

/** {@inheritDoc} */
@Override public boolean remove(Object o) {
  boolean res = deque.remove(o);
  if (res)
    adder.decrement();
  return res;
}

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

private <T> void finished(Deque<T> calls, T call, boolean promoteCalls) {
 int runningCallsCount;
 Runnable idleCallback;
 synchronized (this) {
  if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
  if (promoteCalls) promoteCalls();
  runningCallsCount = runningCallsCount();
  idleCallback = this.idleCallback;
 }
 if (runningCallsCount == 0 && idleCallback != null) {
  idleCallback.run();
 }
}

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

@Override
public void closeScreen(UIScreenLayer screen) {
  if (screens.remove(screen)) {
    ResourceUrn screenUri = screenLookup.inverse().remove(screen);
    onCloseScreen(screen, screenUri, true);
  }
}

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

private static void removeTillMatching(Deque<Term> terms, String begin, String end) {
 assert terms.peek().is(begin);
 terms.remove();
 for (;;) {
  if (terms.peek().is(begin)) {
   removeTillMatching(terms, begin, end);
  } else if (terms.remove().is(end)) {
   return;
  }
 }
}

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

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

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

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

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

private void closeScreen(ResourceUrn screenUri, boolean sendEvents) {
  UIScreenLayer screen = screenLookup.remove(screenUri);
  if (screen != null) {
    screens.remove(screen);
    onCloseScreen(screen, screenUri, sendEvents);
  }
}

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

/** Calls {@link #deallocate()} when {@link #deallocateOnClose} is true,
 * and removes itself from {@link #scopeStack}. */
@Override public void close() {
  if (logger.isDebugEnabled()) {
    logger.debug("Closing " + this);
  }
  if (deallocateOnClose()) {
    deallocate();
  }
  scopeStack.get().remove(this);
}

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

/**
 * Abort all incomplete batches (whether they have been sent or not)
 */
void abortBatches(final RuntimeException reason) {
  for (ProducerBatch batch : incomplete.copyAll()) {
    Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
    synchronized (dq) {
      batch.abortRecordAppends();
      dq.remove(batch);
    }
    batch.abort(reason);
    deallocate(batch);
  }
}

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

/**
 * Abort any batches which have not been drained
 */
void abortUndrainedBatches(RuntimeException reason) {
  for (ProducerBatch batch : incomplete.copyAll()) {
    Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
    boolean aborted = false;
    synchronized (dq) {
      if ((transactionManager != null && !batch.hasSequence()) || (transactionManager == null && !batch.isClosed())) {
        aborted = true;
        batch.abortRecordAppends();
        dq.remove(batch);
      }
    }
    if (aborted) {
      batch.abort(reason);
      deallocate(batch);
    }
  }
}

相关文章