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

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

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

Stack.get介绍

暂无

代码示例

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

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

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

  1. /**
  2. * Find the first node of a type from ancestor stack, starting from parents.
  3. * Returns null if not found.
  4. */
  5. @SuppressWarnings("unchecked")
  6. public static <T> T findNode(Stack<Node> stack, Class<T> target) {
  7. for (int i = stack.size() - 2; i >= 0; i--) {
  8. if (target.isInstance(stack.get(i))) {
  9. return (T) stack.get(i);
  10. }
  11. }
  12. return null;
  13. }
  14. }

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

  1. /**
  2. * 获取当前Activity的前一个Activity
  3. */
  4. public Activity preActivity() {
  5. int index = activityStack.size() - 2;
  6. if (index < 0) {
  7. return null;
  8. }
  9. Activity activity = activityStack.get(index);
  10. return activity;
  11. }

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

  1. /**
  2. * 结束所有Activity
  3. */
  4. public void finishAllActivity() {
  5. for (int i = 0, size = activityStack.size(); i < size; i++) {
  6. if (null != activityStack.get(i)) {
  7. activityStack.get(i).finish();
  8. }
  9. }
  10. activityStack.clear();
  11. }

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

  1. /**
  2. * Find the first node of a type from ancestor stack, starting from parents.
  3. * Returns null if not found.
  4. */
  5. @SuppressWarnings("unchecked")
  6. public static <T> T findNode(Stack<Node> stack, Class<T> target) {
  7. for (int i = stack.size() - 2; i >= 0; i--) {
  8. if (target.isInstance(stack.get(i))) {
  9. return (T) stack.get(i);
  10. }
  11. }
  12. return null;
  13. }
  14. }

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

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

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

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

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

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

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

  1. public static int getPositionParent(AbstractMapJoinOperator<? extends MapJoinDesc> op,
  2. Stack<Node> stack) {
  3. int pos = 0;
  4. int size = stack.size();
  5. assert size >= 2 && stack.get(size - 1) == op;
  6. Operator<? extends OperatorDesc> parent =
  7. (Operator<? extends OperatorDesc>) stack.get(size - 2);
  8. List<Operator<? extends OperatorDesc>> parOp = op.getParentOperators();
  9. pos = parOp.indexOf(parent);
  10. assert pos < parOp.size();
  11. return pos;
  12. }

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

  1. public static int getPositionParent(UnionOperator union, Stack<Node> stack) {
  2. int pos = 0;
  3. int size = stack.size();
  4. assert size >= 2 && stack.get(size - 1) == union;
  5. Operator<? extends OperatorDesc> parent =
  6. (Operator<? extends OperatorDesc>) stack.get(size - 2);
  7. List<Operator<? extends OperatorDesc>> parUnion = union
  8. .getParentOperators();
  9. pos = parUnion.indexOf(parent);
  10. assert pos < parUnion.size();
  11. return pos;
  12. }

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

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

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

  1. public static int getPositionParent(UnionOperator union, Stack<Node> stack) {
  2. int pos = 0;
  3. int size = stack.size();
  4. assert size >= 2 && stack.get(size - 1) == union;
  5. Operator<? extends OperatorDesc> parent =
  6. (Operator<? extends OperatorDesc>) stack.get(size - 2);
  7. List<Operator<? extends OperatorDesc>> parUnion = union
  8. .getParentOperators();
  9. pos = parUnion.indexOf(parent);
  10. assert pos < parUnion.size();
  11. return pos;
  12. }

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

  1. public static int getPositionParent(AbstractMapJoinOperator<? extends MapJoinDesc> op,
  2. Stack<Node> stack) {
  3. int pos = 0;
  4. int size = stack.size();
  5. assert size >= 2 && stack.get(size - 1) == op;
  6. Operator<? extends OperatorDesc> parent =
  7. (Operator<? extends OperatorDesc>) stack.get(size - 2);
  8. List<Operator<? extends OperatorDesc>> parOp = op.getParentOperators();
  9. pos = parOp.indexOf(parent);
  10. assert pos < parOp.size();
  11. return pos;
  12. }

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

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

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

  1. private boolean isTopCase() {
  2. for(int i = 0; i < stack.size(); i++) {
  3. if(!stack.get(i).isGroup()) {
  4. return false;
  5. }
  6. }
  7. return true;
  8. }

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

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

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

  1. protected List<ClassNode> getTemporaryTypesForExpression(final Expression objectExpression) {
  2. List<ClassNode> classNodes = null;
  3. int depth = typeCheckingContext.temporaryIfBranchTypeInformation.size();
  4. while (classNodes == null && depth > 0) {
  5. final Map<Object, List<ClassNode>> tempo = typeCheckingContext.temporaryIfBranchTypeInformation.get(--depth);
  6. Object key = objectExpression instanceof ParameterVariableExpression
  7. ? ((ParameterVariableExpression) objectExpression).parameter
  8. : extractTemporaryTypeInfoKey(objectExpression);
  9. classNodes = tempo.get(key);
  10. }
  11. return classNodes;
  12. }

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

  1. @Override
  2. public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
  3. Object... nodeOutputs) throws SemanticException {
  4. DynamicValuePredicateContext ctx = (DynamicValuePredicateContext) procCtx;
  5. ExprNodeDesc parent = (ExprNodeDesc) stack.get(stack.size() - 2);
  6. if (parent instanceof ExprNodeGenericFuncDesc) {
  7. ExprNodeGenericFuncDesc parentFunc = (ExprNodeGenericFuncDesc) parent;
  8. if (parentFunc.getGenericUDF() instanceof GenericUDFBetween ||
  9. parentFunc.getGenericUDF() instanceof GenericUDFInBloomFilter) {
  10. ExprNodeDesc grandParent = stack.size() >= 3 ?
  11. (ExprNodeDesc) stack.get(stack.size() - 3) : null;
  12. ctx.childParentMapping.put(parentFunc, grandParent);
  13. }
  14. }
  15. return null;
  16. }
  17. }

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

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

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

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

相关文章