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

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

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

ArrayDeque.peekFirst介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private CollectionReference currentCollection() {
  return collectionReferenceStack.peekFirst();
}

代码示例来源:origin: hibernate/hibernate-orm

protected ExpandingFetchSource currentSource() {
  return fetchSourceStack.peekFirst();
}

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

/**
 * Retrieves, but does not remove, the head of the queue represented by
 * this deque, or returns <tt>null</tt> if this deque is empty.
 *
 * <p>This method is equivalent to {@link #peekFirst}.
 *
 * @return the head of the queue represented by this deque, or
 *         <tt>null</tt> if this deque is empty
 */
public E peek() {
  return peekFirst();
}

代码示例来源:origin: real-logic/aeron

private static boolean sendFirst(final ArrayDeque<BooleanSupplier> responseQueue)
{
  return responseQueue.peekFirst().getAsBoolean();
}

代码示例来源:origin: apache/incubator-druid

private void tryEmitOneFailedBuffer()
{
 FailedBuffer failedBuffer = failedBuffers.peekFirst();
 if (failedBuffer != null) {
  if (sendWithRetries(failedBuffer.buffer, failedBuffer.length, failedBuffer.eventCount, false)) {
   // Remove from the queue of failed buffer.
   failedBuffers.pollFirst();
   approximateFailedBuffersCount.decrementAndGet();
   // Don't add the failed buffer back to the buffersToReuse queue here, because in a situation when we were not
   // able to emit events for a while we don't have a way to discard buffers that were used to accumulate events
   // during that period, if they are added back to buffersToReuse. For instance it may result in having 100
   // buffers in rotation even if we need just 2.
  }
 }
}

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

private void updatePlaybackInfo(
  PlaybackInfo playbackInfo,
  boolean positionDiscontinuity,
  @Player.DiscontinuityReason int positionDiscontinuityReason,
  @Player.TimelineChangeReason int timelineChangeReason,
  boolean seekProcessed,
  boolean playWhenReadyChanged) {
 boolean isRunningRecursiveListenerNotification = !pendingPlaybackInfoUpdates.isEmpty();
 pendingPlaybackInfoUpdates.addLast(
   new PlaybackInfoUpdate(
     playbackInfo,
     /* previousPlaybackInfo= */ this.playbackInfo,
     listeners,
     trackSelector,
     positionDiscontinuity,
     positionDiscontinuityReason,
     timelineChangeReason,
     seekProcessed,
     playWhenReady,
     playWhenReadyChanged));
 // Assign playback info immediately such that all getters return the right values.
 this.playbackInfo = playbackInfo;
 if (isRunningRecursiveListenerNotification) {
  return;
 }
 while (!pendingPlaybackInfoUpdates.isEmpty()) {
  pendingPlaybackInfoUpdates.peekFirst().notifyListeners();
  pendingPlaybackInfoUpdates.removeFirst();
 }
}

代码示例来源:origin: hibernate/hibernate-orm

public void pop() {
    pathStack.removeFirst();
    PropertyPath newHead = pathStack.peekFirst();
    MDC.put( MDC_KEY, extractFullPath( newHead ) );
  }
}

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

Pooled<ByteBuffer> getMessage() throws IOException {
  synchronized (lock) {
    for (;;) {
      ByteBuffer first = queue.peekFirst();
      if (first != null) {
        if (first.remaining() >= 4) {
                ByteBufferPool.free(first);
                queue.pollFirst();
                first = queue.peekFirst();

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

MediaCodecInfo codecInfo = availableCodecInfos.peekFirst();
if (!shouldInitCodec(codecInfo)) {
 return false;

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

public void putFirstPrimary(Integer eventCount) {
 if ((queue.peekFirst() == null) || queue.getFirst().intValue() < 0) {
  queue.addFirst(new MutableInteger(eventCount));
 } else {
  queue.getFirst().add(eventCount);
 }
}

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

public void putFirstOverflow(Integer eventCount) {
 if ((queue.peekFirst() == null) || queue.getFirst().intValue() > 0) {
  queue.addFirst(new MutableInteger(-eventCount));
 } else {
  queue.getFirst().add(-eventCount);
 }
 overflowCounter += eventCount;
}

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

while ((cbc = pendingCheckpoints.peekFirst()) != null && cbc.checkpointId() < checkpointId) {
  pendingCheckpoints.removeFirst();

代码示例来源:origin: MobiVM/robovm

/**
 * Retrieves, but does not remove, the head of the queue represented by
 * this deque, or returns <tt>null</tt> if this deque is empty.
 *
 * <p>This method is equivalent to {@link #peekFirst}.
 *
 * @return the head of the queue represented by this deque, or
 *         <tt>null</tt> if this deque is empty
 */
public E peek() {
  return peekFirst();
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Retrieves, but does not remove, the head of the queue represented by
 * this deque, or returns <tt>null</tt> if this deque is empty.
 *
 * <p>This method is equivalent to {@link #peekFirst}.
 *
 * @return the head of the queue represented by this deque, or
 *         <tt>null</tt> if this deque is empty
 */
public E peek() {
  return peekFirst();
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

/**
 * Clean up points that don't count any more (are before our
 * rolling window) from our current queue of points.
 */
private void cleanupOldPoints() {
 Date cutoffTime = new Date(new Date().getTime() - windowSizeMs);
 while (!currentPoints.isEmpty() 
   && currentPoints.peekFirst().getEventTime().before(cutoffTime)) {
  currentPoints.removeFirst();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-azure

/**
 * Clean up points that don't count any more (are before our
 * rolling window) from our current queue of points.
 */
private void cleanupOldPoints() {
 Date cutoffTime = new Date(new Date().getTime() - windowSizeMs);
 while (!currentPoints.isEmpty() 
   && currentPoints.peekFirst().getEventTime().before(cutoffTime)) {
  currentPoints.removeFirst();
 }
}

代码示例来源:origin: org.kie.server/kie-server-client

@Override
public String next() {
  checkEmpty(availableEndpoints);
  if (availableEndpoints.size() == 1) {
    return availableEndpoints.peekFirst();
  }
  return roundRobin();
}

代码示例来源:origin: google/closure-templates

/** Return source location for the first entry in all branches. */
SourceLocation getSourceLocation() {
 removeEmptyDeque();
 if (branches.isEmpty()) {
  return SourceLocation.UNKNOWN;
 }
 ConditionalBranch branch = branches.get(0);
 // removeEmptyDeque guarantees that the deque is not empty.
 return branch.deque().peekFirst().getSourceLocation();
}

代码示例来源:origin: com.google.template/soy

/** Return source location for the first entry in all branches. */
SourceLocation getSourceLocation() {
 removeEmptyDeque();
 if (branches.isEmpty()) {
  return SourceLocation.UNKNOWN;
 }
 ConditionalBranch branch = branches.get(0);
 // removeEmptyDeque guarantees that the deque is not empty.
 return branch.deque().peekFirst().getSourceLocation();
}

代码示例来源:origin: org.apache.flume.flume-ng-channels/flume-spillable-memory-channel

public void putFirstOverflow(Integer eventCount) {
 if ((queue.peekFirst() == null) || queue.getFirst().intValue() > 0) {
  queue.addFirst(new MutableInteger(-eventCount));
 } else {
  queue.getFirst().add(-eventCount);
 }
 overflowCounter += eventCount;
}

相关文章