本文整理了Java中java.util.Stack.add()
方法的一些代码示例,展示了Stack.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.add()
方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:add
暂无
代码示例来源:origin: jenkinsci/jenkins
private Set<AbstractProject> getTransitive(Map<AbstractProject, List<DependencyGroup>> direction, AbstractProject src, boolean up) {
Set<AbstractProject> visited = new HashSet<AbstractProject>();
Stack<AbstractProject> queue = new Stack<AbstractProject>();
queue.add(src);
while(!queue.isEmpty()) {
AbstractProject p = queue.pop();
for (AbstractProject child : get(direction,p,up)) {
if(visited.add(child))
queue.add(child);
}
}
return visited;
}
代码示例来源:origin: gocd/gocd
private Set<Class> findAllInterfacesInHierarchy(Class candidateGoExtensionClass) {
Stack<Class> classesInHierarchy = new Stack<>();
classesInHierarchy.add(candidateGoExtensionClass);
Set<Class> interfaces = new HashSet<>();
while (!classesInHierarchy.empty()) {
Class classToCheckFor = classesInHierarchy.pop();
if (classToCheckFor.isInterface()) {
interfaces.add(classToCheckFor);
}
classesInHierarchy.addAll(Arrays.asList(classToCheckFor.getInterfaces()));
if (classToCheckFor.getSuperclass() != null) {
classesInHierarchy.add(classToCheckFor.getSuperclass());
}
}
return interfaces;
}
代码示例来源:origin: scouter-project/scouter
private static long getEndTime() {
if(stack.size()==0){
for(int i = 0 ; i <24 ; i++){
for(int j=0;j<rate[i] ;j++){
stack.add(i);
}
}
}
int h = stack.pop();
return time + h*3600*1000L +r.nextInt(3600)*1000L;
}
代码示例来源:origin: apache/flink
extractionStates.add(new SharedBufferAccessor.ExtractionState(Tuple2.of(nodeId, entry), version, new Stack<>()));
final SharedBufferAccessor.ExtractionState extractionState = extractionStates.pop();
final NodeId currentPathEntry = currentPath.pop().f0;
代码示例来源:origin: scouter-project/scouter
private static long getEndTime() {
if(stack.size()==0){
for(int i = 0 ; i <24 ; i++){
for(int j=0;j<rate[i] ;j++){
stack.add(i);
}
}
}
int h = stack.pop();
return time + h*3600*1000L +r.nextInt(3600)*1000L;
}
代码示例来源:origin: aws/aws-sdk-java
commonPrefixes.add(keyPrefix);
long totalSize = 0;
String prefix = commonPrefixes.pop();
ObjectListing listObjectsResponse = null;
代码示例来源:origin: cucumber/cucumber-jvm
private static boolean hasAnnotation(Annotation annotation, Collection<Class<? extends Annotation>> desired) {
Set<Class<? extends Annotation>> seen = new HashSet<Class<? extends Annotation>>();
Stack<Class<? extends Annotation>> toCheck = new Stack<Class<? extends Annotation>>();
toCheck.add(annotation.annotationType());
while (!toCheck.isEmpty()) {
Class<? extends Annotation> annotationType = toCheck.pop();
if (desired.contains(annotationType)) {
return true;
}
seen.add(annotationType);
for (Annotation annotationTypesAnnotations : annotationType.getAnnotations()) {
if (!seen.contains(annotationTypesAnnotations.annotationType())) {
toCheck.add(annotationTypesAnnotations.annotationType());
}
}
}
return false;
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Returns the first descendant of a component that is an
* <code>RTextArea</code>. This is primarily here to support
* <code>javax.swing.JLayer</code>s that wrap <code>RTextArea</code>s.
*
* @param comp The component to recursively look through.
* @return The first descendant text area, or <code>null</code> if none
* is found.
*/
private static RTextArea getFirstRTextAreaDescendant(Component comp) {
Stack<Component> stack = new Stack<Component>();
stack.add(comp);
while (!stack.isEmpty()) {
Component current = stack.pop();
if (current instanceof RTextArea) {
return (RTextArea)current;
}
if (current instanceof Container) {
Container container = (Container)current;
stack.addAll(Arrays.asList(container.getComponents()));
}
}
return null;
}
代码示例来源:origin: hankcs/HanLP
s.add(new Integer[]{1, -1});
if (childList == null || (childList.size() - 1) == pair[1])
s.pop();
if (s.empty())
if (base[c] > 0)
s.add(new Integer[]{base[c], -1});
charBuf.add(code);
continue;
代码示例来源:origin: aws-amplify/aws-sdk-android
commonPrefixes.add(keyPrefix);
long totalSize = 0;
final String prefix = commonPrefixes.pop();
ObjectListing listObjectsResponse = null;
代码示例来源:origin: stanfordnlp/CoreNLP
public TreeNode<E,T> balance(TreeNode<E,T> node) {
if (debug) check(node);
Stack<TreeNode<E,T>> todo = new Stack<>();
todo.add(node);
TreeNode<E,T> newRoot = null;
while (!todo.isEmpty()) {
TreeNode<E,T> n = todo.pop();
// Balance tree between this node
// Select median nodes and try to balance the tree
int medianAt = n.size/2;
TreeNode<E,T> median = getNode(n, medianAt);
// Okay, this is going to be our root
if (median != null && median != n) {
// Yes, there is indeed something to be done
rotateUp(median, n);
}
if (newRoot == null) {
newRoot = median;
}
if (median.left != null) todo.push(median.left);
if (median.right != null) todo.push(median.right);
}
if (newRoot == null) return node;
else return newRoot;
}
代码示例来源:origin: facebook/litho
@Override
public List<InspectableComponent> extract(LithoView lithoView) {
final List<InspectableComponent> res = new LinkedList<>();
final Stack<InspectableComponent> stack = new Stack<>();
final InspectableComponent rootInstance = InspectableComponent.getRootInstance(lithoView);
Preconditions.checkNotNull(
rootInstance,
"Could not obtain DebugComponent. "
+ "Please ensure that ComponentsConfiguration.IS_INTERNAL_BUILD is enabled.");
stack.add(rootInstance);
while (!stack.isEmpty()) {
final InspectableComponent inspectableComponent = stack.pop();
res.add(inspectableComponent);
for (InspectableComponent child : inspectableComponent.getChildComponents()) {
stack.push(child);
}
}
return res;
}
代码示例来源:origin: stanfordnlp/CoreNLP
Integer index = fileArrayStackIndices.pop();
int ind = index.intValue();
if (ind < files.length) {
fileArrayStack.pop();
fileArrayStack.pop();
if (obj instanceof String) {
obj = new File((String) obj);
fileArrayStack.add(roots[rootsIndex]);
fileArrayStackIndices.push(Integer.valueOf(0));
代码示例来源:origin: stanfordnlp/CoreNLP
public static <E extends Comparable<E>, T extends HasInterval<E>> boolean overlaps(TreeNode<E,T> node, Interval<E> target) {
Stack<TreeNode<E,T>> todo = new Stack<>();
todo.push(node);
while (!todo.isEmpty()) {
TreeNode<E,T> n = todo.pop();
// Don't search nodes that don't exist
if (n == null || n.isEmpty()) continue;
// If target is to the right of the rightmost point of any interval
// in this node and all children, there won't be any matches.
if (target.first.compareTo(n.maxEnd) > 0)
continue;
// Check this node
if (n.value.getInterval().overlaps(target)) {
return true;
}
// Search left children
if (n.left != null) {
todo.add(n.left);
}
// If target is to the left of the start of this interval,
// then it can't be in any child to the right.
if (target.second.compareTo(n.value.getInterval().first()) < 0) {
continue;
}
if (n.right != null) {
todo.add(n.right);
}
}
return false;
}
代码示例来源:origin: k9mail/k-9
static Part findPartById(Part searchRoot, long partId) {
if (searchRoot instanceof LocalMessage) {
LocalMessage localMessage = (LocalMessage) searchRoot;
if (localMessage.getMessagePartId() == partId) {
return localMessage;
}
}
Stack<Part> partStack = new Stack<>();
partStack.add(searchRoot);
while (!partStack.empty()) {
Part part = partStack.pop();
if (part instanceof LocalPart) {
LocalPart localBodyPart = (LocalPart) part;
if (localBodyPart.getPartId() == partId) {
return part;
}
}
Body body = part.getBody();
if (body instanceof Multipart) {
Multipart innerMultipart = (Multipart) body;
for (BodyPart innerPart : innerMultipart.getBodyParts()) {
partStack.add(innerPart);
}
}
if (body instanceof Part) {
partStack.add((Part) body);
}
}
return null;
}
代码示例来源:origin: pxb1988/dex2jar
stack.add(method.stmts.getFirst());
while (!stack.isEmpty()) {
Stmt currentStmt = stack.pop();
if (currentStmt.visited) {
continue;
Collections.addAll(stack, bs.targets);
LabelStmt target = bs.defaultTarget;
stack.add(target);
stack.add(target);
stack.add(target);
代码示例来源:origin: pedrovgs/Algorithms
/**
* Iterative implementation of this binary tree traversal. The complexity order in time terms of
* this algorithm is O(N) where N is the number of nodes in the tree. In space terms the
* complexity order of this algorithm is also O(N) where N is the number of nodes we have to
* store in the auxiliary data structure, the stack.
*/
public List<BinaryNode> getIterative(BinaryNode root) {
validateBinaryNode(root);
List<BinaryNode> result = new LinkedList<BinaryNode>();
Stack<BinaryNode> stack = new Stack<BinaryNode>();
stack.push(root);
while (!stack.isEmpty()) {
BinaryNode node = stack.pop();
result.add(node);
if (node.hasRight()) {
stack.add(node.getRight());
}
if (node.hasLeft()) {
stack.add(node.getLeft());
}
}
return result;
}
代码示例来源:origin: Alluxio/alluxio
/**
* @param source an Alluxio URI
* @param fileSystem the Alluxio file system
* @return whether the URI is a file or a directory which contains files (including recursively)
* @throws Exception if an unexpected exception occurs
*/
private static boolean hasFiles(AlluxioURI source, FileSystem fileSystem) throws Exception {
Stack<AlluxioURI> dirsToCheck = new Stack<>();
dirsToCheck.add(source);
while (!dirsToCheck.isEmpty()) {
try {
for (URIStatus status : fileSystem.listStatus(dirsToCheck.pop())) {
if (!status.isFolder()) {
return true;
}
dirsToCheck.push(new AlluxioURI(status.getPath()));
}
} catch (FileDoesNotExistException e) {
// This probably means another worker has deleted the directory already, so we can probably
// return false here. To be safe though, we will fall through and complete the search.
}
}
return false;
}
代码示例来源:origin: apache/incubator-pinot
/**
* Extracts all columns from the given filter query tree.
*/
public static Set<String> extractFilterColumns(FilterQueryTree root) {
Set<String> filterColumns = new HashSet<>();
if (root.getChildren() == null) {
filterColumns.add(root.getColumn());
} else {
Stack<FilterQueryTree> stack = new Stack<>();
stack.add(root);
while (!stack.empty()) {
FilterQueryTree node = stack.pop();
for (FilterQueryTree child : node.getChildren()) {
if (child.getChildren() == null) {
filterColumns.add(child.getColumn());
} else {
stack.push(child);
}
}
}
}
return filterColumns;
}
代码示例来源:origin: stanfordnlp/CoreNLP
public void check(TreeNode<E,T> treeNode) {
Stack<TreeNode<E,T>> todo = new Stack<>();
todo.add(treeNode);
while (!todo.isEmpty()) {
TreeNode<E,T> node = todo.pop();
if (node == node.parent) {
throw new IllegalStateException("node is same as parent!!!");
if (node.left != null) todo.add(node.left);
if (node.right != null) todo.add(node.right);
内容来源于网络,如有侵权,请联系作者删除!