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

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

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

LinkedList.push介绍

[英]Pushes an element onto the stack represented by this list. In other words, inserts the element at the front of this list.

This method is equivalent to #addFirst.
[中]将元素推送到此列表表示的堆栈上。换句话说,在列表的前面插入元素。
此方法相当于#addFirst。

代码示例

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

LinkedList<Long> currentQueue = new LinkedList<Long>();
long baseCuboid = Cuboid.getBaseCuboidId(cube);
currentQueue.push(baseCuboid);
    long cuboid = currentQueue.pop();
    Collection<Long> spnanningCuboids = scheduler.getSpanningCuboid(cuboid);

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

stack.push(matchNode);
 stack.pop();
stack.push(matchNode);

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

String repeatId = map.get(OpenDoPEHandler.BINDING_ROLE_REPEAT);
  if (repeatId!=null) {
    repeatContext.push(repeatId);
    mustPopRepeat = true;
repeatContext.pop();

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

@Override
  public <A, B> Optional<Meta<A, B>> transform(Transform<A, B> transform, A model, TransformFactory factory) {
    requireNonNulls(transform, model, factory);

    final RenderTree.Builder parent = renderTreeBuilder.peek();
    final RenderTree.Builder branch = RenderTree.builder();
    
    renderTreeBuilder.push(branch);
    renderStack.push(model);
    
    final Optional<Meta<A, B>> meta = transform
      .transform(this, model)
      .map(s -> Meta.builder(model, s)
        .withTransform(transform)
        .withFactory(factory)
        .withRenderTree(branch.build())
        .withRenderStack(new DefaultRenderStack(renderStack))
        .build()
    );
    
    meta.ifPresent(parent::withBranch);
    
    renderStack.pop();
    renderTreeBuilder.pop();
    
    return meta;
  }
}

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

tblStack.push((Tbl)o);
tblStack.pop();

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

pStack.push((P)parent);
pStack.pop();

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

stack.push(currentField);
stack.pop();
currentField = stack.peek();

代码示例来源:origin: webx/citrus

private boolean buildNamespaceItemRecursively(String namespace) {
  if (buildingNamespaces.contains(namespace)) {
    return false; // 防止递归失控
  }
  try {
    buildingNamespaces.push(namespace);
    buildNamespaceItem(namespace);
  } finally {
    buildingNamespaces.pop();
  }
  return true;
}

代码示例来源:origin: webx/citrus

private boolean buildNamespaceItemRecursively(String namespace) {
  if (buildingNamespaces.contains(namespace)) {
    return false; // 防止递归失控
  }
  try {
    buildingNamespaces.push(namespace);
    buildNamespaceItem(namespace);
  } finally {
    buildingNamespaces.pop();
  }
  return true;
}

代码示例来源:origin: webx/citrus

private boolean buildNamespaceItemRecursively(String namespace) {
  if (buildingNamespaces.contains(namespace)) {
    return false; // 防止递归失控
  }
  try {
    buildingNamespaces.push(namespace);
    buildNamespaceItem(namespace);
  } finally {
    buildingNamespaces.pop();
  }
  return true;
}

代码示例来源:origin: PebbleTemplates/pebble

@Override
public void visit(AutoEscapeNode node) {
 this.active.push(node.isActive());
 this.strategies.push(node.getStrategy());
 node.getBody().accept(this);
 this.active.pop();
 this.strategies.pop();
}

相关文章

微信公众号

最新文章

更多