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

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

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

Deque.pollFirst介绍

[英]Retrieves and removes the first element of this deque, or returns null if this deque is empty.
[中]检索并删除此数据块的第一个元素,如果此数据块为空,则返回null。

代码示例

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

@Override
public E pollFirst() {
 synchronized (mutex) {
  return delegate().pollFirst();
 }
}

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

/**
 * Poll a {@link Channel} out of the internal storage to reuse it. This will return {@code null} if no
 * {@link Channel} is ready to be reused.
 *
 * Sub-classes may override {@link #pollChannel()} and {@link #offerChannel(Channel)}. Be aware that
 * implementations of these methods needs to be thread-safe!
 */
protected Channel pollChannel() {
  return lastRecentUsed ? deque.pollLast() : deque.pollFirst();
}

代码示例来源:origin: AsyncHttpClient/async-http-client

public <E> E lease(Deque<E> d) {
  return d.pollFirst();
 }
},

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

@Override
public byte[] allocate(int size)
{
  synchronized (this) {
    if (bufferQueue.isEmpty()) {
      return new byte[size];
    }
    else {
      return bufferQueue.pollFirst();
    }
  }
}

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

/**
 * Poll a {@link Channel} out of the internal storage to reuse it. This will return {@code null} if no
 * {@link Channel} is ready to be reused.
 *
 * Sub-classes may override {@link #pollChannel()} and {@link #offerChannel(Channel)}. Be aware that
 * implementations of these methods needs to be thread-safe!
 */
protected Channel pollChannel() {
  return lastRecentUsed ? deque.pollLast() : deque.pollFirst();
}

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

@Override
public ByteBuffer get(int size) {
  Deque<ByteBuffer> bufferQueue = bufferMap.get(size);
  if (bufferQueue == null || bufferQueue.isEmpty())
    return ByteBuffer.allocate(size);
  else
    return bufferQueue.pollFirst();
}

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

@Override
public E pollFirst() {
 synchronized (mutex) {
  return delegate().pollFirst();
 }
}

代码示例来源:origin: skylot/jadx

private void store(Level level, String msg) {
  buffer.addLast(new LogEvent(level, msg));
  if (buffer.size() > BUFFER_SIZE) {
    buffer.pollFirst();
  }
}

代码示例来源:origin: Alluxio/alluxio

/**
 * @return the most recently used resource and null if there are no free resources
 */
private ResourceInternal<T> poll() {
 try {
  mLock.lock();
  return mAvailableResources.pollFirst();
 } finally {
  mLock.unlock();
 }
}

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

/**
 * Complete the last request that was sent to a particular node.
 * @param node The node the request was sent to
 * @return The request
 */
public NetworkClient.InFlightRequest completeLastSent(String node) {
  NetworkClient.InFlightRequest inFlightRequest = requestQueue(node).pollFirst();
  inFlightRequestCount.decrementAndGet();
  return inFlightRequest;
}

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

@Override
public E pollFirst() {
 synchronized (mutex) {
  return delegate().pollFirst();
 }
}

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

/**
 * Complete the earliest uncompleted call with the given error.
 *
 * @return true if there was an uncompleted call to complete
 */
public synchronized boolean errorNext(RuntimeException e) {
  Completion completion = this.completions.pollFirst();
  if (completion != null) {
    completion.complete(e);
    return true;
  } else {
    return false;
  }
}

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

public ByteBuffer borrowBuffer() {
  ByteBuffer buffer = availableBuffers.pollFirst();
  if (availableBuffers.size() < poolSize * 0.4) {
    log.warn("TransientStorePool only remain {} sheets.", availableBuffers.size());
  }
  return buffer;
}

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

@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
public E pollFirst() {
 return delegate().pollFirst();
}

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

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

代码示例来源:origin: facebook/litho

@Override
 public void run() {
  final long uptimeMillis = SystemClock.uptimeMillis();
  while (!snapshotCallbacks.isEmpty()) {
   snapshotCallbacks.pollFirst().onDataRendered(isMounted, uptimeMillis);
  }
 }
});

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

/** {@inheritDoc} */
@Override public E pollLast() {
  E res = deque.pollFirst();
  if (res != null)
    adder.decrement();
  return res;
}

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

@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
public E pollFirst() {
 return delegate().pollFirst();
}

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

@CanIgnoreReturnValue // TODO(cpovirk): Consider removing this?
@Override
public E pollFirst() {
 return delegate().pollFirst();
}

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

create().removeFirst();
create().removeLast();
create().pollFirst();
create().pollLast();
create().getFirst();

相关文章