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

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

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

Stack.add介绍

暂无

代码示例

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

  1. private Set<AbstractProject> getTransitive(Map<AbstractProject, List<DependencyGroup>> direction, AbstractProject src, boolean up) {
  2. Set<AbstractProject> visited = new HashSet<AbstractProject>();
  3. Stack<AbstractProject> queue = new Stack<AbstractProject>();
  4. queue.add(src);
  5. while(!queue.isEmpty()) {
  6. AbstractProject p = queue.pop();
  7. for (AbstractProject child : get(direction,p,up)) {
  8. if(visited.add(child))
  9. queue.add(child);
  10. }
  11. }
  12. return visited;
  13. }

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

  1. private static long getEndTime() {
  2. if(stack.size()==0){
  3. for(int i = 0 ; i <24 ; i++){
  4. for(int j=0;j<rate[i] ;j++){
  5. stack.add(i);
  6. }
  7. }
  8. }
  9. int h = stack.pop();
  10. return time + h*3600*1000L +r.nextInt(3600)*1000L;
  11. }

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

  1. extractionStates.add(new SharedBufferAccessor.ExtractionState(Tuple2.of(nodeId, entry), version, new Stack<>()));
  2. final SharedBufferAccessor.ExtractionState extractionState = extractionStates.pop();
  3. final NodeId currentPathEntry = currentPath.pop().f0;

代码示例来源:origin: scouter-project/scouter

  1. private static long getEndTime() {
  2. if(stack.size()==0){
  3. for(int i = 0 ; i <24 ; i++){
  4. for(int j=0;j<rate[i] ;j++){
  5. stack.add(i);
  6. }
  7. }
  8. }
  9. int h = stack.pop();
  10. return time + h*3600*1000L +r.nextInt(3600)*1000L;
  11. }

代码示例来源:origin: aws/aws-sdk-java

  1. commonPrefixes.add(keyPrefix);
  2. long totalSize = 0;
  3. String prefix = commonPrefixes.pop();
  4. ObjectListing listObjectsResponse = null;

代码示例来源:origin: cucumber/cucumber-jvm

  1. private static boolean hasAnnotation(Annotation annotation, Collection<Class<? extends Annotation>> desired) {
  2. Set<Class<? extends Annotation>> seen = new HashSet<Class<? extends Annotation>>();
  3. Stack<Class<? extends Annotation>> toCheck = new Stack<Class<? extends Annotation>>();
  4. toCheck.add(annotation.annotationType());
  5. while (!toCheck.isEmpty()) {
  6. Class<? extends Annotation> annotationType = toCheck.pop();
  7. if (desired.contains(annotationType)) {
  8. return true;
  9. }
  10. seen.add(annotationType);
  11. for (Annotation annotationTypesAnnotations : annotationType.getAnnotations()) {
  12. if (!seen.contains(annotationTypesAnnotations.annotationType())) {
  13. toCheck.add(annotationTypesAnnotations.annotationType());
  14. }
  15. }
  16. }
  17. return false;
  18. }

代码示例来源:origin: bobbylight/RSyntaxTextArea

  1. /**
  2. * Returns the first descendant of a component that is an
  3. * <code>RTextArea</code>. This is primarily here to support
  4. * <code>javax.swing.JLayer</code>s that wrap <code>RTextArea</code>s.
  5. *
  6. * @param comp The component to recursively look through.
  7. * @return The first descendant text area, or <code>null</code> if none
  8. * is found.
  9. */
  10. private static RTextArea getFirstRTextAreaDescendant(Component comp) {
  11. Stack<Component> stack = new Stack<Component>();
  12. stack.add(comp);
  13. while (!stack.isEmpty()) {
  14. Component current = stack.pop();
  15. if (current instanceof RTextArea) {
  16. return (RTextArea)current;
  17. }
  18. if (current instanceof Container) {
  19. Container container = (Container)current;
  20. stack.addAll(Arrays.asList(container.getComponents()));
  21. }
  22. }
  23. return null;
  24. }

代码示例来源:origin: hankcs/HanLP

  1. s.add(new Integer[]{1, -1});
  2. if (childList == null || (childList.size() - 1) == pair[1])
  3. s.pop();
  4. if (s.empty())
  5. if (base[c] > 0)
  6. s.add(new Integer[]{base[c], -1});
  7. charBuf.add(code);
  8. continue;

代码示例来源:origin: aws-amplify/aws-sdk-android

  1. commonPrefixes.add(keyPrefix);
  2. long totalSize = 0;
  3. final String prefix = commonPrefixes.pop();
  4. ObjectListing listObjectsResponse = null;

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

  1. public TreeNode<E,T> balance(TreeNode<E,T> node) {
  2. if (debug) check(node);
  3. Stack<TreeNode<E,T>> todo = new Stack<>();
  4. todo.add(node);
  5. TreeNode<E,T> newRoot = null;
  6. while (!todo.isEmpty()) {
  7. TreeNode<E,T> n = todo.pop();
  8. // Balance tree between this node
  9. // Select median nodes and try to balance the tree
  10. int medianAt = n.size/2;
  11. TreeNode<E,T> median = getNode(n, medianAt);
  12. // Okay, this is going to be our root
  13. if (median != null && median != n) {
  14. // Yes, there is indeed something to be done
  15. rotateUp(median, n);
  16. }
  17. if (newRoot == null) {
  18. newRoot = median;
  19. }
  20. if (median.left != null) todo.push(median.left);
  21. if (median.right != null) todo.push(median.right);
  22. }
  23. if (newRoot == null) return node;
  24. else return newRoot;
  25. }

代码示例来源:origin: facebook/litho

  1. @Override
  2. public List<InspectableComponent> extract(LithoView lithoView) {
  3. final List<InspectableComponent> res = new LinkedList<>();
  4. final Stack<InspectableComponent> stack = new Stack<>();
  5. final InspectableComponent rootInstance = InspectableComponent.getRootInstance(lithoView);
  6. Preconditions.checkNotNull(
  7. rootInstance,
  8. "Could not obtain DebugComponent. "
  9. + "Please ensure that ComponentsConfiguration.IS_INTERNAL_BUILD is enabled.");
  10. stack.add(rootInstance);
  11. while (!stack.isEmpty()) {
  12. final InspectableComponent inspectableComponent = stack.pop();
  13. res.add(inspectableComponent);
  14. for (InspectableComponent child : inspectableComponent.getChildComponents()) {
  15. stack.push(child);
  16. }
  17. }
  18. return res;
  19. }

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

  1. Integer index = fileArrayStackIndices.pop();
  2. int ind = index.intValue();
  3. if (ind < files.length) {
  4. fileArrayStack.pop();
  5. fileArrayStack.pop();
  6. if (obj instanceof String) {
  7. obj = new File((String) obj);
  8. fileArrayStack.add(roots[rootsIndex]);
  9. fileArrayStackIndices.push(Integer.valueOf(0));

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

  1. public static <E extends Comparable<E>, T extends HasInterval<E>> boolean overlaps(TreeNode<E,T> node, Interval<E> target) {
  2. Stack<TreeNode<E,T>> todo = new Stack<>();
  3. todo.push(node);
  4. while (!todo.isEmpty()) {
  5. TreeNode<E,T> n = todo.pop();
  6. // Don't search nodes that don't exist
  7. if (n == null || n.isEmpty()) continue;
  8. // If target is to the right of the rightmost point of any interval
  9. // in this node and all children, there won't be any matches.
  10. if (target.first.compareTo(n.maxEnd) > 0)
  11. continue;
  12. // Check this node
  13. if (n.value.getInterval().overlaps(target)) {
  14. return true;
  15. }
  16. // Search left children
  17. if (n.left != null) {
  18. todo.add(n.left);
  19. }
  20. // If target is to the left of the start of this interval,
  21. // then it can't be in any child to the right.
  22. if (target.second.compareTo(n.value.getInterval().first()) < 0) {
  23. continue;
  24. }
  25. if (n.right != null) {
  26. todo.add(n.right);
  27. }
  28. }
  29. return false;
  30. }

代码示例来源:origin: k9mail/k-9

  1. static Part findPartById(Part searchRoot, long partId) {
  2. if (searchRoot instanceof LocalMessage) {
  3. LocalMessage localMessage = (LocalMessage) searchRoot;
  4. if (localMessage.getMessagePartId() == partId) {
  5. return localMessage;
  6. }
  7. }
  8. Stack<Part> partStack = new Stack<>();
  9. partStack.add(searchRoot);
  10. while (!partStack.empty()) {
  11. Part part = partStack.pop();
  12. if (part instanceof LocalPart) {
  13. LocalPart localBodyPart = (LocalPart) part;
  14. if (localBodyPart.getPartId() == partId) {
  15. return part;
  16. }
  17. }
  18. Body body = part.getBody();
  19. if (body instanceof Multipart) {
  20. Multipart innerMultipart = (Multipart) body;
  21. for (BodyPart innerPart : innerMultipart.getBodyParts()) {
  22. partStack.add(innerPart);
  23. }
  24. }
  25. if (body instanceof Part) {
  26. partStack.add((Part) body);
  27. }
  28. }
  29. return null;
  30. }

代码示例来源:origin: pxb1988/dex2jar

  1. stack.add(method.stmts.getFirst());
  2. while (!stack.isEmpty()) {
  3. Stmt currentStmt = stack.pop();
  4. if (currentStmt.visited) {
  5. continue;
  6. Collections.addAll(stack, bs.targets);
  7. LabelStmt target = bs.defaultTarget;
  8. stack.add(target);
  9. stack.add(target);
  10. stack.add(target);

代码示例来源:origin: pedrovgs/Algorithms

  1. /**
  2. * Iterative implementation of this binary tree traversal. The complexity order in time terms of
  3. * this algorithm is O(N) where N is the number of nodes in the tree. In space terms the
  4. * complexity order of this algorithm is also O(N) where N is the number of nodes we have to
  5. * store in the auxiliary data structure, the stack.
  6. */
  7. public List<BinaryNode> getIterative(BinaryNode root) {
  8. validateBinaryNode(root);
  9. List<BinaryNode> result = new LinkedList<BinaryNode>();
  10. Stack<BinaryNode> stack = new Stack<BinaryNode>();
  11. stack.push(root);
  12. while (!stack.isEmpty()) {
  13. BinaryNode node = stack.pop();
  14. result.add(node);
  15. if (node.hasRight()) {
  16. stack.add(node.getRight());
  17. }
  18. if (node.hasLeft()) {
  19. stack.add(node.getLeft());
  20. }
  21. }
  22. return result;
  23. }

代码示例来源:origin: Alluxio/alluxio

  1. /**
  2. * @param source an Alluxio URI
  3. * @param fileSystem the Alluxio file system
  4. * @return whether the URI is a file or a directory which contains files (including recursively)
  5. * @throws Exception if an unexpected exception occurs
  6. */
  7. private static boolean hasFiles(AlluxioURI source, FileSystem fileSystem) throws Exception {
  8. Stack<AlluxioURI> dirsToCheck = new Stack<>();
  9. dirsToCheck.add(source);
  10. while (!dirsToCheck.isEmpty()) {
  11. try {
  12. for (URIStatus status : fileSystem.listStatus(dirsToCheck.pop())) {
  13. if (!status.isFolder()) {
  14. return true;
  15. }
  16. dirsToCheck.push(new AlluxioURI(status.getPath()));
  17. }
  18. } catch (FileDoesNotExistException e) {
  19. // This probably means another worker has deleted the directory already, so we can probably
  20. // return false here. To be safe though, we will fall through and complete the search.
  21. }
  22. }
  23. return false;
  24. }

代码示例来源:origin: apache/incubator-pinot

  1. /**
  2. * Extracts all columns from the given filter query tree.
  3. */
  4. public static Set<String> extractFilterColumns(FilterQueryTree root) {
  5. Set<String> filterColumns = new HashSet<>();
  6. if (root.getChildren() == null) {
  7. filterColumns.add(root.getColumn());
  8. } else {
  9. Stack<FilterQueryTree> stack = new Stack<>();
  10. stack.add(root);
  11. while (!stack.empty()) {
  12. FilterQueryTree node = stack.pop();
  13. for (FilterQueryTree child : node.getChildren()) {
  14. if (child.getChildren() == null) {
  15. filterColumns.add(child.getColumn());
  16. } else {
  17. stack.push(child);
  18. }
  19. }
  20. }
  21. }
  22. return filterColumns;
  23. }

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

  1. public void check(TreeNode<E,T> treeNode) {
  2. Stack<TreeNode<E,T>> todo = new Stack<>();
  3. todo.add(treeNode);
  4. while (!todo.isEmpty()) {
  5. TreeNode<E,T> node = todo.pop();
  6. if (node == node.parent) {
  7. throw new IllegalStateException("node is same as parent!!!");
  8. if (node.left != null) todo.add(node.left);
  9. if (node.right != null) todo.add(node.right);

相关文章