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

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

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

Stack.addAll介绍

暂无

代码示例

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

  1. public void addCompensationInstances(Collection<NodeInstance> generatedInstances) {
  2. this.compensationInstances.addAll(generatedInstances);
  3. }

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

  1. private synchronized void addTableNamesForPrewarming(List<String> tblNames) {
  2. tableNames.clear();
  3. if (tblNames != null) {
  4. tableNames.addAll(tblNames);
  5. }
  6. }

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

  1. public DirectoryIterator(File... basis) {
  2. this.stack = new Stack<File>();
  3. stack.addAll(Arrays.asList(basis));
  4. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Returns true if a project has a non-direct dependency to another project.
  3. * <p>
  4. * A non-direct dependency is a path of dependency "edge"s from the source to the destination,
  5. * where the length is greater than 1.
  6. */
  7. public boolean hasIndirectDependencies(AbstractProject src, AbstractProject dst) {
  8. Set<AbstractProject> visited = new HashSet<AbstractProject>();
  9. Stack<AbstractProject> queue = new Stack<AbstractProject>();
  10. queue.addAll(getDownstream(src));
  11. queue.remove(dst);
  12. while(!queue.isEmpty()) {
  13. AbstractProject p = queue.pop();
  14. if(p==dst)
  15. return true;
  16. if(visited.add(p))
  17. queue.addAll(getDownstream(p));
  18. }
  19. return false;
  20. }

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

  1. private Set<Class> findAllInterfacesInHierarchy(Class candidateGoExtensionClass) {
  2. Stack<Class> classesInHierarchy = new Stack<>();
  3. classesInHierarchy.add(candidateGoExtensionClass);
  4. Set<Class> interfaces = new HashSet<>();
  5. while (!classesInHierarchy.empty()) {
  6. Class classToCheckFor = classesInHierarchy.pop();
  7. if (classToCheckFor.isInterface()) {
  8. interfaces.add(classToCheckFor);
  9. }
  10. classesInHierarchy.addAll(Arrays.asList(classToCheckFor.getInterfaces()));
  11. if (classToCheckFor.getSuperclass() != null) {
  12. classesInHierarchy.add(classToCheckFor.getSuperclass());
  13. }
  14. }
  15. return interfaces;
  16. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. public void markOptional(boolean propagate) {
  2. this.isOptional = true;
  3. if (propagate && next != null) {
  4. Stack<State> todo = new Stack<>();
  5. Set<State> seen = new HashSet<>();
  6. todo.addAll(next);
  7. while (!todo.empty()) {
  8. State s = todo.pop();
  9. s.isOptional = true;
  10. seen.add(s);
  11. if (next != null) {
  12. for (State n : next) {
  13. if (!seen.contains(n)) {
  14. todo.push(n);
  15. }
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }

代码示例来源:origin: jphp-group/jphp

  1. @Signature
  2. synchronized public void __clone() {
  3. Stack<Memory> old = this.stack;
  4. this.stack = new Stack<Memory>();
  5. stack.addAll(old);
  6. }

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

  1. private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  4. // add all children
  5. opStack.addAll(opSet);
  6. while (!opStack.empty()) {
  7. Operator<?> op = opStack.pop();
  8. returnSet.add(op);
  9. if (op.getChildOperators() != null) {
  10. opStack.addAll(op.getChildOperators());
  11. }
  12. }
  13. return returnSet;
  14. }
  15. }

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

  1. private Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  4. // add all children
  5. opStack.addAll(opSet);
  6. while (!opStack.empty()) {
  7. Operator<?> op = opStack.pop();
  8. returnSet.add(op);
  9. if (op.getChildOperators() != null) {
  10. opStack.addAll(op.getChildOperators());
  11. }
  12. }
  13. return returnSet;
  14. }
  15. }

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

  1. public Set<Operator<?>> getAllOperators() {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Set<Operator<?>> opSet = getAllRootOperators();
  4. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  5. // add all children
  6. opStack.addAll(opSet);
  7. while(!opStack.empty()) {
  8. Operator<?> op = opStack.pop();
  9. returnSet.add(op);
  10. if (op.getChildOperators() != null) {
  11. opStack.addAll(op.getChildOperators());
  12. }
  13. }
  14. return returnSet;
  15. }

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

  1. public Set<Operator<?>> getAllOperators() {
  2. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  3. Set<Operator<?>> opSet = getAllRootOperators();
  4. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  5. // add all children
  6. opStack.addAll(opSet);
  7. while(!opStack.empty()) {
  8. Operator<?> op = opStack.pop();
  9. returnSet.add(op);
  10. if (op.getChildOperators() != null) {
  11. opStack.addAll(op.getChildOperators());
  12. }
  13. }
  14. return returnSet;
  15. }

代码示例来源:origin: graphql-java/graphql-java

  1. /**
  2. * This will decorate a graphql type with the original hierarchy of non null and list'ness
  3. * it originally contained in its definition type
  4. *
  5. * @param objectType this should be a graphql type that was originally built from this raw type
  6. * @param <T> the type
  7. *
  8. * @return the decorated type
  9. */
  10. @SuppressWarnings("TypeParameterUnusedInFormals")
  11. public <T extends GraphQLType> T decorate(GraphQLType objectType) {
  12. GraphQLType out = objectType;
  13. Stack<Class<?>> wrappingStack = new Stack<>();
  14. wrappingStack.addAll(this.decoration);
  15. while (!wrappingStack.isEmpty()) {
  16. Class<?> clazz = wrappingStack.pop();
  17. if (clazz.equals(NonNullType.class)) {
  18. out = nonNull(out);
  19. }
  20. if (clazz.equals(ListType.class)) {
  21. out = list(out);
  22. }
  23. }
  24. // we handle both input and output graphql types
  25. //noinspection unchecked
  26. return (T) out;
  27. }

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

  1. /**
  2. * Returns a set containing all leaf operators from the operator tree in this work.
  3. * @return a set containing all leaf operators in this operator tree.
  4. */
  5. public Set<Operator<? extends OperatorDesc>> getAllLeafOperators() {
  6. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  7. Set<Operator<?>> opSet = getAllRootOperators();
  8. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  9. // add all children
  10. opStack.addAll(opSet);
  11. while (!opStack.empty()) {
  12. Operator<?> op = opStack.pop();
  13. if (op.getNumChild() == 0) {
  14. returnSet.add(op);
  15. }
  16. if (op.getChildOperators() != null) {
  17. opStack.addAll(op.getChildOperators());
  18. }
  19. }
  20. return returnSet;
  21. }

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

  1. public static Set<Operator<?>> getOp(BaseWork work, Class<?> clazz) {
  2. Set<Operator<?>> ops = new HashSet<Operator<?>>();
  3. if (work instanceof MapWork) {
  4. Collection<Operator<?>> opSet = ((MapWork) work).getAliasToWork().values();
  5. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  6. opStack.addAll(opSet);
  7. while (!opStack.empty()) {
  8. Operator<?> op = opStack.pop();
  9. ops.add(op);
  10. if (op.getChildOperators() != null) {
  11. opStack.addAll(op.getChildOperators());
  12. }
  13. }
  14. } else {
  15. ops.addAll(work.getAllOperators());
  16. }
  17. Set<Operator<? extends OperatorDesc>> matchingOps =
  18. new HashSet<Operator<? extends OperatorDesc>>();
  19. for (Operator<? extends OperatorDesc> op : ops) {
  20. if (clazz.isInstance(op)) {
  21. matchingOps.add(op);
  22. }
  23. }
  24. return matchingOps;
  25. }

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

  1. @Override
  2. protected void indexNodes(List<Node> nodes, RuleContext ctx) {
  3. Stack<Node> stack = new Stack<>();
  4. stack.addAll(nodes);
  5. Collections.reverse(stack);
  6. while (!stack.isEmpty()) {
  7. Node node = stack.pop();
  8. indexNode(node);
  9. if (node.jjtGetNumChildren() > 0) {
  10. for (int i = node.jjtGetNumChildren() - 1; i >= 0; i--) {
  11. stack.push(node.jjtGetChild(i));
  12. }
  13. }
  14. }
  15. }

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

  1. @Override
  2. protected void indexNodes(List<Node> nodes, RuleContext ctx) {
  3. // Visit Nodes in DFS order
  4. Stack<Node> stack = new Stack<>();
  5. stack.addAll(nodes);
  6. Collections.reverse(stack);
  7. while (!stack.isEmpty()) {
  8. Node node = stack.pop();
  9. indexNode(node);
  10. if (node.jjtGetNumChildren() > 0) {
  11. for (int i = node.jjtGetNumChildren() - 1; i >= 0; i--) {
  12. stack.push(node.jjtGetChild(i));
  13. }
  14. }
  15. }
  16. }

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

  1. @Override
  2. protected void indexNodes(List<Node> nodes, RuleContext ctx) {
  3. // Visit Nodes in DFS order
  4. Stack<Node> stack = new Stack<>();
  5. stack.addAll(nodes);
  6. Collections.reverse(stack);
  7. while (!stack.isEmpty()) {
  8. Node node = stack.pop();
  9. indexNode(node);
  10. if (node.jjtGetNumChildren() > 0) {
  11. for (int i = node.jjtGetNumChildren() - 1; i >= 0; i--) {
  12. stack.push(node.jjtGetChild(i));
  13. }
  14. }
  15. }
  16. }

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

  1. /**
  2. * Returns a set containing all leaf operators from the operator tree in this work.
  3. * @return a set containing all leaf operators in this operator tree.
  4. */
  5. public Set<Operator<? extends OperatorDesc>> getAllLeafOperators() {
  6. Set<Operator<?>> returnSet = new LinkedHashSet<Operator<?>>();
  7. Set<Operator<?>> opSet = getAllRootOperators();
  8. Stack<Operator<?>> opStack = new Stack<Operator<?>>();
  9. // add all children
  10. opStack.addAll(opSet);
  11. while (!opStack.empty()) {
  12. Operator<?> op = opStack.pop();
  13. if (op.getNumChild() == 0) {
  14. returnSet.add(op);
  15. }
  16. if (op.getChildOperators() != null) {
  17. opStack.addAll(op.getChildOperators());
  18. }
  19. }
  20. return returnSet;
  21. }

代码示例来源:origin: org.apache.logging.log4j/log4j-core

  1. static Stack transform(final List<LogEvent> logEvents) {
  2. final List<String> filtered = new ArrayList<>(logEvents.size());
  3. for (LogEvent event : logEvents) {
  4. filtered.add(event.getMessage().getFormattedMessage());
  5. }
  6. Collections.reverse(filtered);
  7. Stack<String> result = new Stack<>();
  8. result.addAll(filtered);
  9. return result;
  10. }

代码示例来源:origin: remkop/picocli

  1. /**
  2. * Entry point into parsing command line arguments.
  3. * @param args the command line arguments
  4. * @return a list with all commands and subcommands initialized by this method
  5. * @throws ParameterException if the specified command line arguments are invalid
  6. */
  7. List<CommandLine> parse(String... args) {
  8. Assert.notNull(args, "argument array");
  9. if (tracer.isInfo()) {tracer.info("Picocli version: %s%n", versionString());}
  10. if (tracer.isInfo()) {tracer.info("Parsing %d command line args %s%n", args.length, Arrays.toString(args));}
  11. if (tracer.isDebug()){tracer.debug("Parser configuration: %s%n", config());}
  12. if (tracer.isDebug()){tracer.debug("(ANSI is %s by default: isatty=%s, XTERM=%s, OSTYPE=%s, isWindows=%s, JansiConsoleInstalled=%s, ANSICON=%s, ConEmuANSI=%s, NO_COLOR=%s, CLICOLOR=%s, CLICOLOR_FORCE=%s)%n",
  13. Help.Ansi.ansiPossible() ? "enabled" : "disabled", Help.Ansi.isTTY(), System.getenv("XTERM"), System.getenv("OSTYPE"), Help.Ansi.isWindows(), Help.Ansi.isJansiConsoleInstalled(), System.getenv("ANSICON"), System.getenv("ConEmuANSI"), System.getenv("NO_COLOR"), System.getenv("CLICOLOR"), System.getenv("CLICOLOR_FORCE"));}
  14. List<String> expanded = new ArrayList<String>();
  15. for (String arg : args) { addOrExpand(arg, expanded, new LinkedHashSet<String>()); }
  16. Stack<String> arguments = new Stack<String>();
  17. arguments.addAll(reverseList(expanded));
  18. List<CommandLine> result = new ArrayList<CommandLine>();
  19. parse(result, arguments, args, new ArrayList<Object>());
  20. return result;
  21. }

相关文章