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

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

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

Deque.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: checkstyle/checkstyle

/**
 * Update assigned variables in a temporary stack.
 */
private void updateCurrentScopeAssignedVariables() {
  // -@cs[MoveVariableInsideIf] assignment value is a modification call so it can't be moved
  final Deque<DetailAST> poppedScopeAssignedVariableData =
      currentScopeAssignedVariables.pop();
  final Deque<DetailAST> currentScopeAssignedVariableData =
      currentScopeAssignedVariables.peek();
  if (currentScopeAssignedVariableData != null) {
    currentScopeAssignedVariableData.addAll(poppedScopeAssignedVariableData);
  }
}

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

private void recordOpenCloseMethods()
{
  if ( RECORD_STATEMENTS_TRACES )
  {
    if ( statementOpenCloseCalls.size() > STATEMENT_TRACK_HISTORY_MAX_SIZE )
    {
      statementOpenCloseCalls.pop();
    }
    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
    statementOpenCloseCalls.add( Arrays.copyOfRange(stackTrace, 2, stackTrace.length) );
  }
}

代码示例来源:origin: yahoo/squidb

private void setTransactionSuccessful() {
  nestedSuccessStack.pop();
  nestedSuccessStack.push(true);
}

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

do
    lockingTx = graphStack.pop();
    resource = graphStack.pop();
    if ( circle == null )
  while ( !graphStack.isEmpty() );
  throw new DeadlockDetectedException(
      waitingTx + " can't wait on resource " + resource + " since => " + circle );
checkedTransactions.add( lockingTx );
Object resource = waitingTxMap.get( lockingTx );
if ( resource != null )
  graphStack.push( resource );
        graphStack.push( lockingTx );
        checkWaitOnRecursive( lockingTx, waitingTx,
            checkedTransactions, graphStack );
        graphStack.pop();
  graphStack.pop();

代码示例来源:origin: konsoletyper/teavm

List<Range> rangeList = new ArrayList<>();
for (Range range : ranges) {
  rangeList.add(range);
});
Deque<NodeImpl> stack = new ArrayDeque<>();
stack.push(root);
for (Range range : rangeList) {
  NodeImpl current = new NodeImpl();
  current.start = range.left;
  current.end = range.right;
  while (range.right <= stack.peek().start) {
    stack.pop();
  NodeImpl parent = stack.peek();
  current.next = parent.firstChild;
  parent.firstChild = current;
  stack.push(current);

代码示例来源:origin: square/dagger

if (path.contains(name)) {
 StringBuilder message = new StringBuilder("Module Inclusion Cycle: ");
 if (path.size() == 1) {
  message.append(name).append(" includes itself directly.");
 } else {
  String current = null;
  String includer = name;
  for (int i = 0; path.size() > 0; i++) {
   current = includer;
   includer = path.pop();
   message.append("\n").append(i).append(". ")
     .append(current).append(" included by ").append(includer);
List<Object> seedModules = new ArrayList<Object>();
seedModules.addAll(Arrays.asList((Object[]) annotation.get("includes")));
if (!annotation.get("addsTo").equals(Void.class)) seedModules.add(annotation.get("addsTo"));
for (Object include : seedModules) {
 if (!(include instanceof TypeMirror)) {
 path.push(name);
 collectIncludesRecursively(includedModule, result, path);
 path.pop();

代码示例来源:origin: lettuce-io/lettuce-core

@Override
public void complete(int depth) {
  if (counts.isEmpty()) {
    return;
  }
  if (depth == stack.size()) {
    if (stack.peek().size() == counts.peek()) {
      List<Object> pop = stack.pop();
      counts.pop();
      if (!stack.isEmpty()) {
        stack.peek().add(pop);
      }
    }
  }
}

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

final String name = nameIterator.hasNext() ? nameIterator.next() : null;
final String name2 = inferAlias(exprList, node);
names.add(Util.first(name, name2));
} else {
 final Frame frame = stack.pop();
 final RelDataType rowType =
   RexUtil.createStructType(cluster.getTypeFactory(), exprList,
     names, SqlValidatorUtil.F_SUGGESTER);
 stack.push(
   new Frame(frame.rel,
     ImmutableList.of(Pair.of(frame.right.get(0).left, rowType))));

代码示例来源:origin: looly/hutool

/**
 * 切取部分数据<br>
 * 切取后的栈将减少这些元素
 * 
 * @param <T> 集合元素类型
 * @param surplusAlaDatas 原数据
 * @param partSize 每部分数据的长度
 * @return 切取出的数据或null
 */
public static <T> List<T> popPart(Deque<T> surplusAlaDatas, int partSize) {
  if (isEmpty(surplusAlaDatas)) {
    return null;
  }
  final List<T> currentAlaDatas = new ArrayList<>();
  int size = surplusAlaDatas.size();
  // 切割
  if (size > partSize) {
    for (int i = 0; i < partSize; i++) {
      currentAlaDatas.add(surplusAlaDatas.pop());
    }
  } else {
    for (int i = 0; i < size; i++) {
      currentAlaDatas.add(surplusAlaDatas.pop());
    }
  }
  return currentAlaDatas;
}

代码示例来源:origin: kiegroup/optaplanner

@Override
public Iterable<Vfs.File> getFiles() {
  List<Vfs.File> vfsFileList = new ArrayList<>();
  Deque<Resource> resourceDeque = new ArrayDeque<>();
  Collection<? extends Resource> mainMembers = kieFolder.getMembers();
  if (mainMembers != null) {
    resourceDeque.addAll(mainMembers);
  }
  while (!resourceDeque.isEmpty()) {
    Resource resource = resourceDeque.pop();
    if (resource instanceof File) {
      File file = (File) resource;
      if (file.getName().endsWith(".class")) {
        vfsFileList.add(new ReflectionsKieVfsFile(file));
      }
    } else if (resource instanceof Folder) {
      Collection<? extends Resource> members = ((Folder) resource).getMembers();
      if (members != null) {
        resourceDeque.addAll(members);
      }
    } else {
      throw new IllegalStateException("Unsupported resource class (" + resource.getClass()
          + ") for resource (" + resource + ").");
    }
  }
  return vfsFileList;
}

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

final List<RexNode> originalExtraNodes = ImmutableList.copyOf(extraNodes);
for (RexNode node : nodes) {
 fieldCollations.add(
   collation(node, RelFieldCollation.Direction.ASCENDING, null,
     extraNodes));
  final Sort sort2 = (Sort) top;
  if (sort2.offset == null && sort2.fetch == null) {
   stack.pop();
   push(sort2.getInput());
   final RelNode sort =
   final Sort sort2 = (Sort) project.getInput();
   if (sort2.offset == null && sort2.fetch == null) {
    stack.pop();
    push(sort2.getInput());
    final RelNode sort =

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

@Override
public boolean hasNext()
{
  if (geometriesDeque.isEmpty()) {
    return false;
  }
  while (geometriesDeque.peek() instanceof OGCConcreteGeometryCollection) {
    OGCGeometryCollection collection = (OGCGeometryCollection) geometriesDeque.pop();
    for (int i = 0; i < collection.numGeometries(); i++) {
      geometriesDeque.push(collection.geometryN(i));
    }
  }
  return !geometriesDeque.isEmpty();
}

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

private static Map<File, Long> doScan(File file) {
  final Map<File, Long> results = new HashMap<File, Long>();
  final Deque<File> toScan = new ArrayDeque<File>();
  toScan.add(file);
  while (!toScan.isEmpty()) {
    File next = toScan.pop();
    if (next.isDirectory()) {
      results.put(next, next.lastModified());
      File[] list = next.listFiles();
      if (list != null) {
        for (File f : list) {
          toScan.push(new File(f.getAbsolutePath()));
        }
      }
    }
  }
  return results;
}

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

public String getFullName() {
  if (cachedPackageFullName == null) {
    Deque<PackageNode> pp = getParentPackages();
    StringBuilder result = new StringBuilder();
    result.append(pp.pop().getName());
    while (!pp.isEmpty()) {
      result.append(SEPARATOR_CHAR);
      result.append(pp.pop().getName());
    }
    cachedPackageFullName = result.toString();
  }
  return cachedPackageFullName;
}

代码示例来源:origin: com.h2database/h2

/**
 * Stores name of currently parsed view in a stack so it can be determined
 * during {@code prepare()}.
 *
 * @param parsingView
 *            {@code true} to store one more name, {@code false} to remove it
 *            from stack
 * @param viewName
 *            name of the view
 */
public void setParsingCreateView(boolean parsingView, String viewName) {
  // It can be recursive, thus implemented as counter.
  this.parsingView += parsingView ? 1 : -1;
  assert this.parsingView >= 0;
  if (parsingView) {
    viewNameStack.push(viewName);
  } else {
    assert viewName.equals(viewNameStack.peek());
    viewNameStack.pop();
  }
}
public String getParsingCreateViewName() {

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

public void testHoldsLockOnAllOperations() {
 create().element();
 create().offer("foo");
 create().peek();
 create().poll();
 create().remove();
 create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
 create().hashCode();
 create().isEmpty();
 create().iterator();
 create().remove("foo");
 create().removeAll(ImmutableList.of("foo"));
 create().retainAll(ImmutableList.of("foo"));
 create().size();
 create().toArray();
 create().toArray(new String[] {"foo"});
 create().removeFirstOccurrence("e");
 create().removeLastOccurrence("e");
 create().push("e");
 create().pop();
 create().descendingIterator();

代码示例来源:origin: linkedin/parseq

private void loop() {
  //  Entering state:
  //  - _siblingActions is empty
  //  - _preOrderExecutionStack has one element
  //  - _inLoop is false
  _inLoop = true;
  try {
   do {
    _preOrderExecutionStack.pop().run();
    // currentAction could have submitted a few children actions, so we pop them out from
    // _siblingActions & push them into _preOrderExecutionStack, resulting in the desired
    // pre-order execution
    while (_siblingActions.size() > 0) {
     _preOrderExecutionStack.push(_siblingActions.pop());
    }
   } while (_preOrderExecutionStack.size() > 0);
  } finally {
   // maintain invariants
   _preOrderExecutionStack.clear();
   _siblingActions.clear();
   _inLoop = false;
  }
  //  Exiting state (even when exception is thrown):
  //  - _siblingActions is empty
  //  - _preOrderExecutionStack is empty
  //  - _inLoop is false
 }
}

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

switch(opcode) {
  case Opcodes.POP: {
    if (simulatedStack.pop()) {
      return;
    if (simulatedStack.size() < 2) return;
    Boolean[] vals = new Boolean[2];
    int cntr = vals.length - 1;
    while (cntr >= 0) {
      vals[cntr--] = simulatedStack.pop();
    if (simulatedStack.size() < 3) return;
    Boolean[] vals = new Boolean[3];
    int cntr = vals.length - 1;
    while (cntr >= 0) {
      vals[cntr--] = simulatedStack.pop();
    if (simulatedStack.size() < 2) return;
    Boolean[] vals = new Boolean[2];
    int cntr = vals.length - 1;
    while (cntr >= 0) {
      vals[cntr--] = simulatedStack.pop();
    int cntr = vals.length - 1;
    while (cntr >= 0) {
      vals[cntr--] = simulatedStack.pop();
      vals[cntr--] = simulatedStack.pop();

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

/**
 * End a {@link Scope} by removing {@code this} from a {@link java.util.Deque} contained in a
 * {@link java.lang.ThreadLocal}.
 * If {@code this} isn't on the top of the Deque, an {@link IllegalStateException} will be thrown, as that signals a
 * process is trying to end somebody else's scope.
 * If the Deque is empty, it will be removed from the ThreadLocal.
 */
protected void endScope() {
  Deque<Scope> scopes = CURRENT_SCOPE.get();
  if (this != scopes.peek()) {
    throw new IllegalStateException(
        "Incorrectly trying to end another Scope then which the calling process is contained in."
    );
  }
  scopes.pop();
  if (scopes.isEmpty()) {
    logger.debug("Clearing out ThreadLocal current Scope, as no Scopes are present");
    CURRENT_SCOPE.remove();
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

private static void printServerError(String msg,
    Deque<ComponentInfo> attributes, boolean widthError,
    PrintStream errorStream) {
  StringBuilder err = new StringBuilder();
  err.append("Vaadin DEBUG\n");
  StringBuilder indent = new StringBuilder();
  ComponentInfo ci;
  if (attributes != null) {
    while (attributes.size() > LAYERS_SHOWN) {
      attributes.pop();
    }
    while (!attributes.isEmpty()) {
      ci = attributes.pop();
      showComponent(ci.component, ci.info, err, indent, widthError);
    }
  }
  err.append("Layout problem detected: ");
  err.append(msg);
  err.append("\n");
  err.append(
      "Relative sizes were replaced by undefined sizes, components may not render as expected.\n");
  errorStream.println(err);
}

相关文章