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

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

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

ArrayDeque.removeFirst介绍

暂无

代码示例

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

/**
 * Pops an element from the stack represented by this deque.  In other
 * words, removes and returns the first element of this deque.
 *
 * <p>This method is equivalent to {@link #removeFirst()}.
 *
 * @return the element at the front of this deque (which is the top
 *         of the stack represented by this deque)
 * @throws NoSuchElementException {@inheritDoc}
 */
public E pop() {
  return removeFirst();
}

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

/**
 * Retrieves and removes the head of the queue represented by this deque.
 *
 * This method differs from {@link #poll poll} only in that it throws an
 * exception if this deque is empty.
 *
 * <p>This method is equivalent to {@link #removeFirst}.
 *
 * @return the head of the queue represented by this deque
 * @throws NoSuchElementException {@inheritDoc}
 */
public E remove() {
  return removeFirst();
}

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

/**
 * Triggers the next queued runnable and executes it synchronously.
 * This method throws an exception if no Runnable is currently queued.
 */
public void trigger() {
  final Runnable next;
  synchronized (queuedRunnables) {
    next = queuedRunnables.removeFirst();
  }
  if (next != null) {
    next.run();
  }
  else {
    throw new IllegalStateException("No runnable available");
  }
}

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

@Override
public final O dequeueOutputBuffer() throws E {
 synchronized (lock) {
  maybeThrowException();
  if (queuedOutputBuffers.isEmpty()) {
   return null;
  }
  return queuedOutputBuffers.removeFirst();
 }
}

代码示例来源:origin: org.apache.lucene/lucene-core

public ByteBuffer allocate(int size) {
 while (!reuse.isEmpty()) {
  ByteBuffer bb = reuse.removeFirst();
  // If we don't have a buffer of exactly the requested size, discard it.
  if (bb.remaining() == size) {
   return bb;
  }
 }
 return delegate.apply(size);        
}

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

private ExpandingFetchSource popFromStack() {
  final ExpandingFetchSource last = fetchSourceStack.removeFirst();
  log.trace( "Popped fetch owner from stack : " + last );
  propertyPathStack.pop();
  return last;
}

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

private CollectionReference popFromCollectionStack() {
  final CollectionReference last = collectionReferenceStack.removeFirst();
  log.trace( "Popped collection reference from stack : " + last );
  propertyPathStack.pop();
  return last;
}

代码示例来源:origin: ReactiveX/RxJava

/**
 * Returns a flattened list of Throwables from tree-like CompositeException chain.
 * @param t the starting throwable
 * @return the list of Throwables flattened in a depth-first manner
 */
public static List<Throwable> flatten(Throwable t) {
  List<Throwable> list = new ArrayList<Throwable>();
  ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
  deque.offer(t);
  while (!deque.isEmpty()) {
    Throwable e = deque.removeFirst();
    if (e instanceof CompositeException) {
      CompositeException ce = (CompositeException) e;
      List<Throwable> exceptions = ce.getExceptions();
      for (int i = exceptions.size() - 1; i >= 0; i--) {
        deque.offerFirst(exceptions.get(i));
      }
    } else {
      list.add(e);
    }
  }
  return list;
}

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

/**
 * Returns the queue's next element and removes it, the queue is non-empty.
 * Otherwise, this method returns null.
 *
 * <p>The method throws an {@code IllegalStateException} if the queue is closed.
 * Checking whether the queue is open and removing the next element is one atomic operation.
 *
 * <p>This method never blocks.
 *
 * @return The queue's next element, or null, if the queue is empty.
 * @throws IllegalStateException Thrown, if the queue is closed.
 */
public E poll() {
  lock.lock();
  try {
    if (open) {
      if (elements.size() > 0) {
        return elements.removeFirst();
      } else {
        return null;
      }
    } else {
      throw new IllegalStateException("queue is closed");
    }
  } finally {
    lock.unlock();
  }
}

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

/**
 * Returns the next element in the queue. If the queue is empty, this method
 * waits until at least one element is added.
 *
 * <p>The method throws an {@code IllegalStateException} if the queue is closed.
 * Checking whether the queue is open and removing the next element is one atomic operation.
 *
 * @return The next element in the queue, never null.
 *
 * @throws IllegalStateException Thrown, if the queue is closed.
 * @throws InterruptedException Throw, if the thread is interrupted while waiting for an
 *                              element to be added.
 */
public E getElementBlocking() throws InterruptedException {
  lock.lock();
  try {
    while (open && elements.isEmpty()) {
      nonEmpty.await();
    }
    if (open) {
      return elements.removeFirst();
    } else {
      throw new IllegalStateException("queue is closed");
    }
  } finally {
    lock.unlock();
  }
}

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

private void limitFailedBuffersSize()
{
 if (failedBuffers.size() >= config.getBatchQueueSizeLimit()) {
  failedBuffers.removeFirst();
  approximateFailedBuffersCount.decrementAndGet();
  droppedBuffers.incrementAndGet();
  log.error(
    "failedBuffers queue size reached the limit [%d], dropping the oldest failed buffer",
    config.getBatchQueueSizeLimit()
  );
 }
}

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

@Override
public final void flush() {
 synchronized (lock) {
  flushed = true;
  skippedOutputBufferCount = 0;
  if (dequeuedInputBuffer != null) {
   releaseInputBufferInternal(dequeuedInputBuffer);
   dequeuedInputBuffer = null;
  }
  while (!queuedInputBuffers.isEmpty()) {
   releaseInputBufferInternal(queuedInputBuffers.removeFirst());
  }
  while (!queuedOutputBuffers.isEmpty()) {
   queuedOutputBuffers.removeFirst().release();
  }
 }
}

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

/**
 * Returns a flattened list of Throwables from tree-like CompositeException chain.
 * @param t the starting throwable
 * @return the list of Throwables flattened in a depth-first manner
 */
public static List<Throwable> flatten(Throwable t) {
  List<Throwable> list = new ArrayList<Throwable>();
  ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
  deque.offer(t);
  while (!deque.isEmpty()) {
    Throwable e = deque.removeFirst();
    if (e instanceof CompositeException) {
      CompositeException ce = (CompositeException) e;
      List<Throwable> exceptions = ce.getExceptions();
      for (int i = exceptions.size() - 1; i >= 0; i--) {
        deque.offerFirst(exceptions.get(i));
      }
    } else {
      list.add(e);
    }
  }
  return list;
}

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

private void outputPendingMetadataSamples(long sampleTimeUs) {
 while (!pendingMetadataSampleInfos.isEmpty()) {
  MetadataSampleInfo sampleInfo = pendingMetadataSampleInfos.removeFirst();
  pendingMetadataSampleBytes -= sampleInfo.size;
  long metadataTimeUs = sampleTimeUs + sampleInfo.presentationTimeDeltaUs;
  if (timestampAdjuster != null) {
   metadataTimeUs = timestampAdjuster.adjustSampleTimestamp(metadataTimeUs);
  }
  for (TrackOutput emsgTrackOutput : emsgTrackOutputs) {
   emsgTrackOutput.sampleMetadata(
     metadataTimeUs,
     C.BUFFER_FLAG_KEY_FRAME,
     sampleInfo.size,
     pendingMetadataSampleBytes,
     null);
  }
 }
}

代码示例来源: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: apache/flume

public void takeOverflow(int takeCount) {
 MutableInteger headValue = queue.getFirst();
 if (headValue.intValue() > -takeCount) {
  throw new IllegalStateException("Cannot take " + takeCount + " from "
    + headValue.intValue() + " in DrainOrder Queue head ");
 }
 headValue.add(takeCount);
 if (headValue.intValue() == 0) {
  queue.removeFirst();
 }
 overflowCounter -= takeCount;
}

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

public void takePrimary(int takeCount) {
 MutableInteger headValue = queue.getFirst();
 // this condition is optimization to avoid redundant conversions of
 // int -> Integer -> string in hot path
 if (headValue.intValue() < takeCount) {
  throw new IllegalStateException("Cannot take " + takeCount +
    " from " + headValue.intValue() + " in DrainOrder Queue");
 }
 headValue.add(-takeCount);
 if (headValue.intValue() == 0) {
  queue.removeFirst();
 }
}

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

return null;
} else if (!resourceHolderList.isEmpty()) {
 ResourceHolder<V> holder = resourceHolderList.removeFirst();
 if (System.currentTimeMillis() - holder.getLastAccessedTime() > unusedResourceTimeoutMillis) {
  factory.close(holder.getResource());

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

pendingCheckpoints.removeFirst();
  pendingCheckpoints.removeFirst();

相关文章

微信公众号

最新文章

更多