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

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

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

ArrayDeque.pop介绍

[英]Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

This method is equivalent to #removeFirst().
[中]从这个deque表示的堆栈中弹出一个元素。换句话说,删除并返回此数据块的第一个元素。
此方法相当于#removeFirst()。

代码示例

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

public void pop() {
  wrapped = wrappedStack.pop();
}

代码示例来源:origin: RuedigerMoeller/fast-serialization

public void pop() {
  wrapped = wrappedStack.pop();
}

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

@Nullable
private T pollObject()
{
 final ReentrantLock lock = this.lock;
 lock.lock();
 try {
  return objects.isEmpty() ? null : objects.pop();
 }
 finally {
  lock.unlock();
 }
}

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

private T takeObject() throws InterruptedException
{
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  while (objects.isEmpty()) {
   notEnough.await();
  }
  return objects.pop();
 }
 finally {
  lock.unlock();
 }
}

代码示例来源:origin: iluwatar/java-design-patterns

/**
 * @return TreeNode next. The next element according to our in-order traversal of the given BST
 * @throws NoSuchElementException if this iterator does not have a next element
 */
@Override
public TreeNode<T> next() throws NoSuchElementException {
 if (pathStack.isEmpty()) {
  throw new NoSuchElementException();
 }
 TreeNode<T> next = pathStack.pop();
 pushPathToNextSmallest(next.getRight());
 return next;
}

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

public String popNdc() {
  ArrayDeque<Entry> stack = ndcStack.get();
  return stack == null || stack.isEmpty() ? "" : stack.pop().current;
}

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

public void setNdcMaxDepth(int maxDepth) {
  final ArrayDeque<Entry> stack = ndcStack.get();
  if (stack != null) while (stack.size() > maxDepth) stack.pop();
}

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

private List<T> takeObjects(int elementNum) throws InterruptedException
{
 final List<T> list = new ArrayList<>(elementNum);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  while (objects.size() < elementNum) {
   notEnough.await();
  }
  for (int i = 0; i < elementNum; i++) {
   list.add(objects.pop());
  }
  return list;
 }
 finally {
  lock.unlock();
 }
}

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

private List<T> pollObjects(int elementNum) throws InterruptedException
{
 final List<T> list = new ArrayList<>(elementNum);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  if (objects.size() < elementNum) {
   return Collections.emptyList();
  } else {
   for (int i = 0; i < elementNum; i++) {
    list.add(objects.pop());
   }
   return list;
  }
 }
 finally {
  lock.unlock();
 }
}

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

@Nullable
private T pollObject(long timeoutMs) throws InterruptedException
{
 long nanos = TIME_UNIT.toNanos(timeoutMs);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  while (objects.isEmpty()) {
   if (nanos <= 0) {
    return null;
   }
   nanos = notEnough.awaitNanos(nanos);
  }
  return objects.pop();
 }
 finally {
  lock.unlock();
 }
}

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

private List<T> pollObjects(int elementNum, long timeoutMs) throws InterruptedException
{
 long nanos = TIME_UNIT.toNanos(timeoutMs);
 final List<T> list = new ArrayList<>(elementNum);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  while (objects.size() < elementNum) {
   if (nanos <= 0) {
    return Collections.emptyList();
   }
   nanos = notEnough.awaitNanos(nanos);
  }
  for (int i = 0; i < elementNum; i++) {
   list.add(objects.pop());
  }
  return list;
 }
 finally {
  lock.unlock();
 }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void distributeEvents() {
  //add collision callbacks
  int clistsize = collisionListeners.size();
  while( collisionEvents.isEmpty() == false ) {
    PhysicsCollisionEvent physicsCollisionEvent = collisionEvents.pop();
    for(int i=0;i<clistsize;i++) {
      collisionListeners.get(i).collision(physicsCollisionEvent);
    }
    //recycle events
    eventFactory.recycle(physicsCollisionEvent);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Distribute each collision event to all listeners.
 */
public void distributeEvents() {
  //add collision callbacks
  int clistsize = collisionListeners.size();
  while( collisionEvents.isEmpty() == false ) {
    PhysicsCollisionEvent physicsCollisionEvent = collisionEvents.pop();
    for(int i=0;i<clistsize;i++) {
      collisionListeners.get(i).collision(physicsCollisionEvent);
    }
    //recycle events
    eventFactory.recycle(physicsCollisionEvent);
  }
}

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

private void processAtomEnded(long atomEndPosition) throws ParserException {
 while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == atomEndPosition) {
  onContainerAtomRead(containerAtoms.pop());
 }
 enterReadingAtomHeaderState();
}

代码示例来源:origin: google/error-prone

private static void findUnannotatedTypeVarRefs(
  TypeVariableSymbol typeVar,
  Tree sourceNode,
  Type type,
  ArrayDeque<Integer> partialSelector,
  ImmutableSet.Builder<InferenceVariable> resultBuilder) {
 List<Type> typeArguments = type.getTypeArguments();
 for (int i = 0; i < typeArguments.size(); i++) {
  partialSelector.push(i);
  findUnannotatedTypeVarRefs(
    typeVar, sourceNode, typeArguments.get(i), partialSelector, resultBuilder);
  partialSelector.pop();
 }
 if (type.tsym.equals(typeVar) && !toNullness(type.getAnnotationMirrors()).isPresent()) {
  resultBuilder.add(
    TypeArgInferenceVar.create(ImmutableList.copyOf(partialSelector), sourceNode));
 }
}

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

@Override
void handleClose() {
 if (pendingPushes.remove(this)) {
  completionHandler.fail("Push reset by client");
 } else {
  concurrentStreams--;
  while ((maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) && pendingPushes.size() > 0) {
   Push push = pendingPushes.pop();
   concurrentStreams++;
   context.runOnContext(v -> {
    push.complete();
   });
  }
  response.handleClose();
 }
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
public void exitMessageRef(RuleLangParser.MessageRefContext ctx) {
  isIdIsFieldAccess.pop(); // reset for error checks
  final Expression fieldExpr = exprs.get(ctx.field);
  final MessageRefExpression expr = new MessageRefExpression(ctx.getStart(), fieldExpr);
  log.trace("$MSG: ctx {} => {}", ctx, expr);
  exprs.put(ctx, expr);
}

代码示例来源:origin: google/error-prone

private void generateConstraintsFromAnnotations(
  Type type, Tree sourceTree, ArrayDeque<Integer> argSelector) {
 List<Type> typeArguments = type.getTypeArguments();
 int numberOfTypeArgs = typeArguments.size();
 for (int i = 0; i < numberOfTypeArgs; i++) {
  argSelector.push(i);
  generateConstraintsFromAnnotations(typeArguments.get(i), sourceTree, argSelector);
  argSelector.pop();
 }
 // Use equality constraints even for top-level type, since we want to "trust" the annotation
 // TODO(b/121398981): skip for T extends @<Annot> since they constrain one side only
 ProperInferenceVar.fromTypeIfAnnotated(type)
   .ifPresent(
     annot -> {
      qualifierConstraints.putEdge(
        TypeArgInferenceVar.create(ImmutableList.copyOf(argSelector), sourceTree), annot);
      qualifierConstraints.putEdge(
        annot, TypeArgInferenceVar.create(ImmutableList.copyOf(argSelector), sourceTree));
     });
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
public void exitNested(RuleLangParser.NestedContext ctx) {
  isIdIsFieldAccess.pop(); // reset for error checks
  final Expression object = exprs.get(ctx.fieldSet);
  final Expression field = exprs.get(ctx.field);
  final FieldAccessExpression expr = new FieldAccessExpression(ctx.getStart(), object, field);
  log.trace("FIELDACCESS: ctx {} => {}", ctx, expr);
  exprs.put(ctx, expr);
}

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

private void processAtomEnded(long atomEndPosition) throws ParserException {
 while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == atomEndPosition) {
  Atom.ContainerAtom containerAtom = containerAtoms.pop();
  if (containerAtom.type == Atom.TYPE_moov) {
   // We've reached the end of the moov atom. Process it and prepare to read samples.
   processMoovAtom(containerAtom);
   containerAtoms.clear();
   parserState = STATE_READING_SAMPLE;
  } else if (!containerAtoms.isEmpty()) {
   containerAtoms.peek().add(containerAtom);
  }
 }
 if (parserState != STATE_READING_SAMPLE) {
  enterReadingAtomHeaderState();
 }
}

相关文章