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

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

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

LinkedList.pop介绍

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

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

代码示例

代码示例来源:origin: stackoverflow.com

int number; // = and int
LinkedList<Integer> stack = new LinkedList<Integer>();
while (number > 0) {
  stack.push( number % 10 );
  number = number / 10;
}

while (!stack.isEmpty()) {
  print(stack.pop());
}

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

protected void executeTemporaryJobs() {
 while (!temporaryJobQueue.isEmpty()) {
  Job job = temporaryJobQueue.pop();
  executeAsyncJob(job);
 }
}

代码示例来源:origin: deeplearning4j/nd4j

/** Convert an arbitrary-dimensional rectangular double array to flat vector.<br>
 * Can pass double[], double[][], double[][][], etc.
 */
public static double[] flattenDoubleArray(Object doubleArray) {
  if (doubleArray instanceof double[])
    return (double[]) doubleArray;
  LinkedList<Object> stack = new LinkedList<>();
  stack.push(doubleArray);
  int[] shape = arrayShape(doubleArray);
  int length = ArrayUtil.prod(shape);
  double[] flat = new double[length];
  int count = 0;
  while (!stack.isEmpty()) {
    Object current = stack.pop();
    if (current instanceof double[]) {
      double[] arr = (double[]) current;
      for (int i = 0; i < arr.length; i++)
        flat[count++] = arr[i];
    } else if (current instanceof Object[]) {
      Object[] o = (Object[]) current;
      for (int i = o.length - 1; i >= 0; i--)
        stack.push(o[i]);
    } else
      throw new IllegalArgumentException("Base array is not double[]");
  }
  if (count != flat.length)
    throw new IllegalArgumentException("Fewer elements than expected. Array is ragged?");
  return flat;
}

代码示例来源:origin: weibocom/motan

char operand = list.pop();
if (operand != '0' && operand != '1') {
  syntaxError();
while (!list.isEmpty()) {
  char curr = list.pop();
  if (curr == '!') {
    operand = operand == '0' ? '1' : '0';
operand = list.pop();
while (!list.isEmpty()) {
  char curr = list.pop();
  if (curr == '&') {
    char c = list.pop();
    operand = (operand == '1' && c == '1') ? '1' : '0';
  } else if (curr == '#') {
while (!list.isEmpty() && (operand = list.pop()) != '1');
return operand;

代码示例来源:origin: deeplearning4j/nd4j

/** Convert an arbitrary-dimensional rectangular float array to flat vector.<br>
 * Can pass float[], float[][], float[][][], etc.
 */
public static float[] flattenFloatArray(Object floatArray) {
  if (floatArray instanceof float[])
    return (float[]) floatArray;
  LinkedList<Object> stack = new LinkedList<>();
  stack.push(floatArray);
  int[] shape = arrayShape(floatArray);
  int length = ArrayUtil.prod(shape);
  float[] flat = new float[length];
  int count = 0;
  while (!stack.isEmpty()) {
    Object current = stack.pop();
    if (current instanceof float[]) {
      float[] arr = (float[]) current;
      for (int i = 0; i < arr.length; i++)
        flat[count++] = arr[i];
    } else if (current instanceof Object[]) {
      Object[] o = (Object[]) current;
      for (int i = o.length - 1; i >= 0; i--)
        stack.push(o[i]);
    } else
      throw new IllegalArgumentException("Base array is not float[]");
  }
  if (count != flat.length)
    throw new IllegalArgumentException("Fewer elements than expected. Array is ragged?");
  return flat;
}

代码示例来源:origin: plutext/docx4j

private boolean preserveParentResult() {
  
  FieldRef thisField = stack.pop();
  FieldRef parentField = stack.pop();
  boolean preserveParentResult = preserveResult(parentField);
  // restore stack
  stack.push(parentField);
  stack.push(thisField);
  return preserveParentResult;
}

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

protected void flattenTree() {
 flattenedList = new LinkedList<ExecutionTreeNode>();
 LinkedList<ExecutionTreeNode> nodesToHandle = new LinkedList<ExecutionTreeNode>();
 nodesToHandle.add(rootNode);
 while (!nodesToHandle.isEmpty()) {
  ExecutionTreeNode currentNode = nodesToHandle.pop();
  if (reverseOrder) {
   flattenedList.addFirst(currentNode);
  } else {
   flattenedList.add(currentNode);
  }
  if (currentNode.getChildren() != null && currentNode.getChildren().size() > 0) {
   for (ExecutionTreeNode childNode : currentNode.getChildren()) {
    nodesToHandle.add(childNode);
   }
  }
 }
 flattenedListIterator = flattenedList.iterator();
}

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

LinkedList<Long> currentQueue = new LinkedList<Long>();
long baseCuboid = Cuboid.getBaseCuboidId(cube);
currentQueue.push(baseCuboid);
  while (!currentQueue.isEmpty()) {
    long cuboid = currentQueue.pop();
    Collection<Long> spnanningCuboids = scheduler.getSpanningCuboid(cuboid);
    if (!currentQueue.isEmpty()) {
      throw new IllegalStateException();

代码示例来源:origin: plutext/docx4j

private boolean inParentResult() {
  
  FieldRef thisField = stack.pop();
  try {
    FieldRef parentField = stack.pop();
    boolean inResult = parentField.haveSeenSeparate();
    // restore stack
    stack.push(parentField);
    stack.push(thisField);
    return inResult;
  } catch (NoSuchElementException e) {
    // No parent
    // restore stack
    stack.push(thisField);
    return false;
  }
  
}

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

if (_slots.isEmpty()) {
  return false;
Set<ExecutorDetails> slot = _slots.pop();
if (slot == _lastSlot) {
return !_slots.isEmpty();

代码示例来源:origin: fesh0r/fernflower

if (stack.isEmpty()) { // first line, root node
 stack.push(matchNode);
  stack.pop();
 stack.push(matchNode);

代码示例来源:origin: plutext/docx4j

tr.push(document.createElementNS(Namespaces.NS_WORD12, "tr"));
tc.push(document.createElementNS(Namespaces.NS_WORD12, "tc"));
(tr.peek()).appendChild(tc.peek());
tr.pop();
tc.pop();

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

private static void bulk( final LinkedList<Log> remaining, final ArrayList<Log> bulkLogs, final Consumer<Log> finalConsumer )
{
  if ( !remaining.isEmpty() )
  {
    Log log = remaining.pop();
    log.bulk( bulkLog ->
    {
      bulkLogs.add( bulkLog );
      bulk( remaining, bulkLogs, finalConsumer );
    } );
  }
  else
  {
    Log log = new DuplicatingLog( bulkLogs );
    finalConsumer.accept( log );
  }
}

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

cuboidSet.add(baseCuboid);
LinkedList<Long> cuboidQueue = new LinkedList<Long>();
cuboidQueue.push(baseCuboid);
while (!cuboidQueue.isEmpty()) {
  long cuboid = cuboidQueue.pop();
  Collection<Long> spnanningCuboids = scheduler.getSpanningCuboid(cuboid);
  for (Long sc : spnanningCuboids) {
    cuboidQueue.push(sc);

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

private static FieldNode buildTreeByExpr(String expr) {
  int index = 0;
  LinkedList<FieldNode> fieldStack = new LinkedList<>();
  while (index < expr.length()) {
   int i = index;
   if (isSpecialChar(expr.charAt(i))) {
    if ((expr.charAt(index) == ',') || (expr.charAt(index) == ']')) {
     FieldNode node = fieldStack.pop();
     FieldNode pre = fieldStack.peek();
     pre.addFieldNodes(node);
    }
    index++;
   } else {
    while (i < expr.length() && !isSpecialChar(expr.charAt(i))) {
     i++;
    }
    FieldNode current = new FieldNode(expr.substring(index, i));
    fieldStack.push(current);
    index = i;
   }
  }
  return fieldStack.pop();
 }
}

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

private static void bulk( final LinkedList<Logger> remaining, final ArrayList<Logger> bulkLoggers,
      final Consumer<Logger> finalConsumer )
  {
    if ( !remaining.isEmpty() )
    {
      Logger logger = remaining.pop();
      logger.bulk( bulkLogger ->
      {
        bulkLoggers.add( bulkLogger );
        bulk( remaining, bulkLoggers, finalConsumer );
      } );
    }
    else
    {
      Logger logger = new DuplicatingLogger( bulkLoggers );
      finalConsumer.accept( logger );
    }
  }
}

代码示例来源:origin: KylinOLAP/Kylin

public static int[] calculateAllLevelCount(CubeDesc cube) {
  int levels = cube.getRowkey().getNCuboidBuildLevels();
  int[] allLevelCounts = new int[levels + 1];
  CuboidScheduler scheduler = new CuboidScheduler(cube);
  LinkedList<Long> nextQueue = new LinkedList<Long>();
  LinkedList<Long> currentQueue = new LinkedList<Long>();
  long baseCuboid = Cuboid.getBaseCuboidId(cube);
  currentQueue.push(baseCuboid);
  for (int i = 0; i <= levels; i++) {
    allLevelCounts[i] = currentQueue.size();
    while (!currentQueue.isEmpty()) {
      long cuboid = currentQueue.pop();
      Collection<Long> spnanningCuboids = scheduler.getSpanningCuboid(cuboid);
      nextQueue.addAll(spnanningCuboids);
    }
    currentQueue = nextQueue;
    nextQueue = new LinkedList<Long>();
  }
  return allLevelCounts;
}

代码示例来源:origin: plutext/docx4j

listStack.peek().sdtList.getSdtContent().getContent().add(listSpec.sdtList);
listStack.push(listSpec);
    listStack.peek().sdtList.getSdtContent().getContent().add(listSpec.sdtList);
  listStack.push(listSpec);
  listStack.pop();
  listSpec = listStack.peek();
  log.debug("popped!");

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

if (_slots.isEmpty()) {
  return false;
Set<ExecutorDetails> slot = _slots.pop();
if (slot == _lastSlot) {
return !_slots.isEmpty();

代码示例来源:origin: KylinOLAP/Kylin

public static int simulateCuboidGeneration(CubeDesc cube) {
  CuboidScheduler scheduler = new CuboidScheduler(cube);
  long baseCuboid = Cuboid.getBaseCuboidId(cube);
  Collection<Long> cuboidSet = new TreeSet<Long>();
  cuboidSet.add(baseCuboid);
  LinkedList<Long> cuboidQueue = new LinkedList<Long>();
  cuboidQueue.push(baseCuboid);
  while (!cuboidQueue.isEmpty()) {
    long cuboid = cuboidQueue.pop();
    Collection<Long> spnanningCuboids = scheduler.getSpanningCuboid(cuboid);
    for (Long sc : spnanningCuboids) {
      boolean notfound = cuboidSet.add(sc);
      if (!notfound) {
        throw new IllegalStateException("Find duplicate spanning cuboid " + sc + " from cuboid " + cuboid);
      }
      cuboidQueue.push(sc);
    }
  }
  TreeSet<Long> enumCuboids = enumCalcCuboidCount(cube);
  if (enumCuboids.equals(cuboidSet) == false) {
    throw new IllegalStateException("Expected cuboid set " + enumCuboids + "; but actual cuboid set " + cuboidSet);
  }
  int mathCount = mathCalcCuboidCount(cube);
  if (mathCount != enumCuboids.size()) {
    throw new IllegalStateException("Math cuboid count " + mathCount + ", but actual cuboid count " + enumCuboids.size());
  }
  return mathCount;
}

相关文章

微信公众号

最新文章

更多