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

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

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

Deque.peekFirst介绍

[英]Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
[中]检索但不删除此deque的第一个元素,如果此deque为空,则返回null。

代码示例

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

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

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

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

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

@Override
public E peekFirst() {
 return delegate().peekFirst();
}

代码示例来源:origin: alibaba/jstorm

@Override
public void putHead(K key, V value) {
  buckets.peekFirst().put(key, value);
}

代码示例来源:origin: twosigma/beakerx

public void pushBrace(Brace b) {
  braceStack.push(b);
  topBrace = braceStack.peekFirst();
  //System.out.println("> " + topBrace);
}

代码示例来源:origin: twosigma/beakerx

public void popBrace() {
  braceStack.pop();
  topBrace = braceStack.peekFirst();
  //System.out.println("> " + topBrace);
}

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

/**
 * Can we send more requests to this node?
 *
 * @param node Node in question
 * @return true iff we have no requests still being sent to the given node
 */
public boolean canSendMore(String node) {
  Deque<NetworkClient.InFlightRequest> queue = requests.get(node);
  return queue == null || queue.isEmpty() ||
      (queue.peekFirst().send.completed() && queue.size() < this.maxInFlightRequestsPerConnection);
}

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

/**
 * Get the last request we sent to the given node (but don't remove it from the queue)
 * @param node The node id
 */
public NetworkClient.InFlightRequest lastSent(String node) {
  return requestQueue(node).peekFirst();
}

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

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

代码示例来源:origin: btraceio/btrace

public static <V> V peekFirst(Deque<V> queue) {
  if (queue instanceof BTraceDeque || queue.getClass().getClassLoader() == null) {
    return queue.peekFirst();
  } else {
    throw new IllegalArgumentException();
  }
}

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

@Override
public E peekFirst() {
 return delegate().peekFirst();
}

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

/**
 * Return buffers to the pool. If they are of the poolable size add them to the free list, otherwise just mark the
 * memory as free.
 *
 * @param buffer The buffer to return
 * @param size The size of the buffer to mark as deallocated, note that this may be smaller than buffer.capacity
 *             since the buffer may re-allocate itself during in-place compression
 */
public void deallocate(ByteBuffer buffer, int size) {
  lock.lock();
  try {
    if (size == this.poolableSize && size == buffer.capacity()) {
      buffer.clear();
      this.free.add(buffer);
    } else {
      this.nonPooledAvailableMemory += size;
    }
    Condition moreMem = this.waiters.peekFirst();
    if (moreMem != null)
      moreMem.signal();
  } finally {
    lock.unlock();
  }
}

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

@Override
public E peekFirst() {
 return delegate().peekFirst();
}

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

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

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

/**
 * Allocate a buffer.  If buffer allocation fails (e.g. because of OOM) then return the size count back to
 * available memory and signal the next waiter if it exists.
 */
private ByteBuffer safeAllocateByteBuffer(int size) {
  boolean error = true;
  try {
    ByteBuffer buffer = allocateByteBuffer(size);
    error = false;
    return buffer;
  } finally {
    if (error) {
      this.lock.lock();
      try {
        this.nonPooledAvailableMemory += size;
        if (!this.waiters.isEmpty())
          this.waiters.peekFirst().signal();
      } finally {
        this.lock.unlock();
      }
    }
  }
}

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

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

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

private void awaitPendingPartsUpload() throws IOException {
  checkState(currentUploadInfo.getRemainingParts() == uploadsInProgress.size());
  while (currentUploadInfo.getRemainingParts() > 0) {
    CompletableFuture<PartETag> next = uploadsInProgress.peekFirst();
    PartETag nextPart = awaitPendingPartUploadToComplete(next);
    currentUploadInfo.registerCompletePart(nextPart);
    uploadsInProgress.removeFirst();
  }
}

代码示例来源:origin: ben-manes/caffeine

private void checkDeque(Deque<? extends E> deque, DescriptionBuilder builder) {
 builder.expectThat("empty deque", deque.peekFirst(), is(nullValue()));
 builder.expectThat("empty deque", deque.peekLast(), is(nullValue()));
 builder.expectThat("empty deque", deque.descendingIterator().hasNext(), is(false));
}

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

/**
 * @return details about one synchronization conflict.
 */
public IdentityConflict getNextConflict() {
  IdentityBundle entry = conflictingRemoteIdentities.peekFirst();
  return new IdentityConflict(entry.getServer(), securityConfig.getIdentity(entry.getServer()), entry.getClient());
}

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

create().getFirst();
create().getLast();
create().peekFirst();
create().peekLast();
create().removeFirstOccurrence("e");

相关文章