java.util.Stack.get()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(178)

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

Stack.get介绍

暂无

代码示例

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

private static String getStackString(KsonCharInput in) {
  if ( in instanceof KsonStringCharInput && ((KsonStringCharInput) in).stack != null) {
    final Stack<KsonDeserializer.ParseStep> stack = ((KsonStringCharInput) in).stack;
    StringBuilder res = new StringBuilder("\n\n");
    for (int i = stack.size()-1; i >= 0; i--) {
      KsonDeserializer.ParseStep parseStep = stack.get(i);
      res.append("  ").append(parseStep).append("\n");
    }
    return res.toString();
  }
  return null;
}

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

/**
  * Find the first node of a type from ancestor stack, starting from parents.
  * Returns null if not found.
  */
 @SuppressWarnings("unchecked")
 public static <T> T findNode(Stack<Node> stack, Class<T> target) {
  for (int i = stack.size() - 2; i >= 0; i--) {
   if (target.isInstance(stack.get(i))) {
    return (T) stack.get(i);
   }
  }
  return null;
 }
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
 * 获取当前Activity的前一个Activity
 */
public Activity preActivity() {
  int index = activityStack.size() - 2;
  if (index < 0) {
    return null;
  }
  Activity activity = activityStack.get(index);
  return activity;
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

/**
 * 结束所有Activity
 */
public void finishAllActivity() {
  for (int i = 0, size = activityStack.size(); i < size; i++) {
    if (null != activityStack.get(i)) {
      activityStack.get(i).finish();
    }
  }
  activityStack.clear();
}

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

/**
  * Find the first node of a type from ancestor stack, starting from parents.
  * Returns null if not found.
  */
 @SuppressWarnings("unchecked")
 public static <T> T findNode(Stack<Node> stack, Class<T> target) {
  for (int i = stack.size() - 2; i >= 0; i--) {
   if (target.isInstance(stack.get(i))) {
    return (T) stack.get(i);
   }
  }
  return null;
 }
}

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

@Override
 public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
            Object... nodeOutputs) throws SemanticException {
  SemiJoinCycleRemovalDueTOMapsideJoinContext ctx =
      (SemiJoinCycleRemovalDueTOMapsideJoinContext) procCtx;
  ctx.childParentMap.put((Operator<?>)stack.get(stack.size() - 2), (Operator<?>) nd);
  return null;
 }
}

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

public Stack<Model> getModelsByType(String type) {
  Stack<Model> mdls = new Stack<Model>();
  
  for(int i=0; i<models.size(); ++i)
    if(models.get(i).type.equals(type))
      mdls.add(models.get(i));
  
  return mdls;
}

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

private boolean supportBucketMapJoin(Stack<Node> stack) {
 int size = stack.size();
 if (!(stack.get(size - 1) instanceof JoinOperator)
  || !(stack.get(size - 2) instanceof ReduceSinkOperator)) {
  return false;
 }
 // If any operator in the stack does not support a auto-conversion, this join should
 // not be converted.
 for (int pos = size - 3; pos >= 0; pos--) {
  @SuppressWarnings("unchecked")
  Operator<? extends OperatorDesc> op = (Operator<? extends OperatorDesc>) stack.get(pos);
  if (!op.supportAutomaticSortMergeJoin()) {
   return false;
  }
 }
 return true;
}

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

public static int getPositionParent(AbstractMapJoinOperator<? extends MapJoinDesc> op,
  Stack<Node> stack) {
 int pos = 0;
 int size = stack.size();
 assert size >= 2 && stack.get(size - 1) == op;
 Operator<? extends OperatorDesc> parent =
   (Operator<? extends OperatorDesc>) stack.get(size - 2);
 List<Operator<? extends OperatorDesc>> parOp = op.getParentOperators();
 pos = parOp.indexOf(parent);
 assert pos < parOp.size();
 return pos;
}

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

public static int getPositionParent(UnionOperator union, Stack<Node> stack) {
 int pos = 0;
 int size = stack.size();
 assert size >= 2 && stack.get(size - 1) == union;
 Operator<? extends OperatorDesc> parent =
  (Operator<? extends OperatorDesc>) stack.get(size - 2);
 List<Operator<? extends OperatorDesc>> parUnion = union
   .getParentOperators();
 pos = parUnion.indexOf(parent);
 assert pos < parUnion.size();
 return pos;
}

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

private boolean supportBucketMapJoin(Stack<Node> stack) {
 int size = stack.size();
 if (!(stack.get(size - 1) instanceof JoinOperator)
  || !(stack.get(size - 2) instanceof ReduceSinkOperator)) {
  return false;
 }
 // If any operator in the stack does not support a auto-conversion, this join should
 // not be converted.
 for (int pos = size - 3; pos >= 0; pos--) {
  @SuppressWarnings("unchecked")
  Operator<? extends OperatorDesc> op = (Operator<? extends OperatorDesc>) stack.get(pos);
  if (!op.supportAutomaticSortMergeJoin()) {
   return false;
  }
 }
 return true;
}

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

public static int getPositionParent(UnionOperator union, Stack<Node> stack) {
 int pos = 0;
 int size = stack.size();
 assert size >= 2 && stack.get(size - 1) == union;
 Operator<? extends OperatorDesc> parent =
  (Operator<? extends OperatorDesc>) stack.get(size - 2);
 List<Operator<? extends OperatorDesc>> parUnion = union
   .getParentOperators();
 pos = parUnion.indexOf(parent);
 assert pos < parUnion.size();
 return pos;
}

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

public static int getPositionParent(AbstractMapJoinOperator<? extends MapJoinDesc> op,
  Stack<Node> stack) {
 int pos = 0;
 int size = stack.size();
 assert size >= 2 && stack.get(size - 1) == op;
 Operator<? extends OperatorDesc> parent =
   (Operator<? extends OperatorDesc>) stack.get(size - 2);
 List<Operator<? extends OperatorDesc>> parOp = op.getParentOperators();
 pos = parOp.indexOf(parent);
 assert pos < parOp.size();
 return pos;
}

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

private static String getStackString(KsonCharInput in) {
  if ( in instanceof KsonStringCharInput && ((KsonStringCharInput) in).stack != null) {
    final Stack<KsonDeserializer.ParseStep> stack = ((KsonStringCharInput) in).stack;
    StringBuilder res = new StringBuilder("\n\n");
    for (int i = stack.size()-1; i >= 0; i--) {
      KsonDeserializer.ParseStep parseStep = stack.get(i);
      res.append("  ").append(parseStep).append("\n");
    }
    return res.toString();
  }
  return null;
}

代码示例来源:origin: osmandapp/Osmand

private boolean isTopCase() {
  for(int i = 0; i < stack.size(); i++) {
    if(!stack.get(i).isGroup()) {
      return false;
    }
  }
  return true;
}

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

/** Return null if cannot be resolved as a variable in current scope */
private CompiledValue resolveAsVariable(String name) {
 CompiledValue value = null;
 for (int i = scopes.size() - 1; i >= 0; i--) {
  QScope scope = (QScope) scopes.get(i);
  value = scope.resolve(name);
  if (value != null)
   return value;
 }
 return null;
}

代码示例来源:origin: org.codehaus.groovy/groovy

protected List<ClassNode> getTemporaryTypesForExpression(final Expression objectExpression) {
  List<ClassNode> classNodes = null;
  int depth = typeCheckingContext.temporaryIfBranchTypeInformation.size();
  while (classNodes == null && depth > 0) {
    final Map<Object, List<ClassNode>> tempo = typeCheckingContext.temporaryIfBranchTypeInformation.get(--depth);
    Object key = objectExpression instanceof ParameterVariableExpression
        ? ((ParameterVariableExpression) objectExpression).parameter
        : extractTemporaryTypeInfoKey(objectExpression);
    classNodes = tempo.get(key);
  }
  return classNodes;
}

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

@Override
 public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
            Object... nodeOutputs) throws SemanticException {
  DynamicValuePredicateContext ctx = (DynamicValuePredicateContext) procCtx;
  ExprNodeDesc parent = (ExprNodeDesc) stack.get(stack.size() - 2);
  if (parent instanceof ExprNodeGenericFuncDesc) {
   ExprNodeGenericFuncDesc parentFunc = (ExprNodeGenericFuncDesc) parent;
   if (parentFunc.getGenericUDF() instanceof GenericUDFBetween ||
       parentFunc.getGenericUDF() instanceof GenericUDFInBloomFilter) {
    ExprNodeDesc grandParent = stack.size() >= 3 ?
        (ExprNodeDesc) stack.get(stack.size() - 3) : null;
    ctx.childParentMapping.put(parentFunc, grandParent);
   }
  }
  return null;
 }
}

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

/**
  * process simply remembers all the dynamic partition pruning expressions
  * found
  */
 @Override
 public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
   Object... nodeOutputs) throws SemanticException {
  ExprNodeDynamicListDesc desc = (ExprNodeDynamicListDesc) nd;
  DynamicPartitionPrunerContext context = (DynamicPartitionPrunerContext) procCtx;
  // Rule is searching for dynamic pruning expr. There's at least an IN
  // expression wrapping it.
  ExprNodeDesc parent = (ExprNodeDesc) stack.get(stack.size() - 2);
  ExprNodeDesc grandParent = stack.size() >= 3 ? (ExprNodeDesc) stack.get(stack.size() - 3) : null;
  context.addDynamicList(desc, parent, grandParent, (ReduceSinkOperator) desc.getSource());
  return context;
 }
}

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

@Override
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
  Object... nodeOutputs) throws SemanticException {
 GroupByOperator mGby = (GroupByOperator) stack.get(stack.size() - 3);
 ReduceSinkOperator rs = (ReduceSinkOperator) stack.get(stack.size() - 2);
 GroupByOperator rGby = (GroupByOperator) stack.get(stack.size() - 1);
 int applicableDistPos = checkCountDistinct(mGby, rs, rGby);
 if (applicableDistPos != -1) {
  LOG.info("trigger count distinct rewrite");
  try {
   processGroupBy(mGby, rs, rGby, applicableDistPos);
  } catch (CloneNotSupportedException e) {
   throw new SemanticException(e.getMessage());
  }
 }
 return null;
}

相关文章