本文整理了Java中java.util.Stack.push()
方法的一些代码示例,展示了Stack.push()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.push()
方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:push
[英]Pushes the specified object onto the top of the stack.
[中]将指定的对象推到堆栈顶部。
代码示例来源:origin: alibaba/druid
private static List<SQLSelectQueryBlock> splitSQLSelectQuery(SQLSelectQuery x) {
List<SQLSelectQueryBlock> groupList = new ArrayList<SQLSelectQueryBlock>();
Stack<SQLSelectQuery> stack = new Stack<SQLSelectQuery>();
stack.push(x);
do {
SQLSelectQuery query = stack.pop();
if (query instanceof SQLSelectQueryBlock) {
groupList.add((SQLSelectQueryBlock) query);
} else if (query instanceof SQLUnionQuery) {
SQLUnionQuery unionQuery = (SQLUnionQuery) query;
stack.push(unionQuery.getLeft());
stack.push(unionQuery.getRight());
}
} while (!stack.empty());
return groupList;
}
代码示例来源:origin: apache/usergrid
/**
* Push a new fieldname on to the stack
*/
private void pushField( final String fieldName ) {
if ( fieldStack.isEmpty() ) {
fieldStack.push( fieldName );
return;
}
final String newFieldName = fieldStack.peek() + "." + fieldName;
fieldStack.push( newFieldName );
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
String tagName = localName.toUpperCase(Locale.ENGLISH);
// make sure that this tag occurs in the proper context
if(!elements.peek().isAllowed(tagName))
throw new SAXException(tagName+" is not allowed inside "+tagNames.peek());
Checker next = CHECKERS.get(tagName);
if(next==null) next = ALL_ALLOWED;
elements.push(next);
tagNames.push(tagName);
super.startElement(uri, localName, qName, atts);
}
代码示例来源:origin: jenkinsci/jenkins
private void visit(N p) throws CycleDetectedException {
if (!visited.add(p)) return;
visiting.add(p);
path.push(p);
for (N q : getEdges(p)) {
if (q==null) continue; // ignore unresolved references
if (visiting.contains(q))
detectedCycle(q);
visit(q);
}
visiting.remove(p);
path.pop();
topologicalOrder.add(p);
}
代码示例来源:origin: apache/hive
/**
* walk the current operator and its descendants.
*
* @param nd
* current operator in the graph
* @throws SemanticException
*/
@Override
protected void walk(Node nd) throws SemanticException {
if (opStack.empty() || nd != opStack.peek()) {
opStack.push(nd);
}
if (allParentsDispatched(nd)) {
// all children are done or no need to walk the children
if (!getDispatchedList().contains(nd)) {
toWalk.addAll(nd.getChildren());
dispatch(nd, opStack);
}
opStack.pop();
return;
}
// add children, self to the front of the queue in that order
toWalk.add(0, nd);
addAllParents(nd);
}
}
代码示例来源:origin: galenframework/galen
public void pushSection(PageSection pageSection) {
LayoutSection section = new LayoutSection(pageSection.getName(), pageSection.getPlace());
if (!sectionStack.isEmpty()) {
sectionStack.peek().addSection(section);
}
else {
layoutReport.getSections().add(section);
}
sectionStack.push(section);
}
代码示例来源:origin: stackoverflow.com
import java.util.*;
public class Test
{
public static void main(String[] args)
{
Stack<String> stack = new Stack<String>();
stack.push("Bottom");
stack.push("Middle");
stack.push("Top");
List<String> list = new ArrayList<String>(stack);
for (String x : list)
{
System.out.println(x);
}
}
}
代码示例来源:origin: jenkinsci/jenkins
synchronized void push(RunExecution r) {
Executor e = Executor.currentExecutor();
Stack<RunExecution> s = stack.get(e);
if(s==null) stack.put(e,s=new Stack<RunExecution>());
s.push(r);
}
代码示例来源:origin: org.codehaus.groovy/groovy
private GroovySourceAST getGrandParentNode() {
Object currentNode = stack.pop();
Object parentNode = stack.pop();
Object grandParentNode = stack.peek();
stack.push(parentNode);
stack.push(currentNode);
return (GroovySourceAST) grandParentNode;
}
}
代码示例来源:origin: pmd/pmd
private Object init(JavaNode node, Object data) {
stack.push(count);
count = NumericConstants.ZERO;
node.childrenAccept(this, data);
if (count > 1) {
addViolation(data, node);
}
count = stack.pop();
return data;
}
代码示例来源:origin: jenkinsci/jenkins
String[] p = path.split("/");
Stack<String> name = new Stack<String>();
for (int i=0; i<c.length;i++) {
if (i==0 && c[i].equals("")) continue;
name.push(c[i]);
));
name.pop();
continue;
continue;
name.push(p[i]);
代码示例来源:origin: stanfordnlp/CoreNLP
@Override
void advance() {
if (searchStack.isEmpty()) {
next = null;
} else {
next = searchStack.pop();
if (pathMatchesNode(next)) {
for (int i = next.numChildren() - 1; i >= 0; i--) {
searchStack.push(next.getChild(i));
}
}
}
}
};
代码示例来源:origin: stanfordnlp/CoreNLP
@Override
public void initialize() {
searchStack = new Stack<>();
for (int i = t.numChildren() - 1; i >= 0; i--) {
searchStack.push(t.getChild(i));
}
if (!searchStack.isEmpty()) {
advance();
}
}
代码示例来源:origin: Sable/soot
@Override
protected soot.Value getSimpleAssignRightLocal(polyglot.ast.Assign assign) {
boolean repush = false;
soot.jimple.Stmt tNoop = null;
soot.jimple.Stmt fNoop = null;
if (!trueNoop.empty() && !falseNoop.empty()) {
tNoop = trueNoop.pop();
fNoop = falseNoop.pop();
repush = true;
}
soot.Value right = base().createAggressiveExpr(assign.right(), false, false);
if (repush) {
trueNoop.push(tNoop);
falseNoop.push(fNoop);
}
if (right instanceof soot.jimple.ConditionExpr) {
right = handleCondBinExpr((soot.jimple.ConditionExpr) right);
}
return right;
}
代码示例来源:origin: jphp-group/jphp
public Scope addScope(boolean isRoot) {
Scope scope = new Scope(scopeStack.empty() ? null : scopeStack.peek());
scopeStack.push(scope);
if (isRoot)
rootScopeStack.push(scope);
return scope;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private void flushParents(List<Record> willReturn){
Stack<RepeatedRecordInfo> reverseStack = new Stack<>();
while(!stack.isEmpty()){
reverseStack.push(stack.pop());
}
while(!reverseStack.isEmpty()){
RepeatedRecordInfo info = reverseStack.pop();
info.timesSeen -= 1;
flush(info, willReturn);
stack.push(info);
}
}
代码示例来源:origin: org.testng/testng
private void run(Graph<T> graph, T v) {
m_indices.put(v, m_index);
m_lowlinks.put(v, m_index);
m_index++;
m_s.push(v);
for (T vprime : graph.getPredecessors(v)) {
if (! m_indices.containsKey(vprime)) {
run(graph, vprime);
int min = Math.min(m_lowlinks.get(v), m_lowlinks.get(vprime));
m_lowlinks.put(v, min);
}
else if (m_s.contains(vprime)) {
m_lowlinks.put(v, Math.min(m_lowlinks.get(v), m_indices.get(vprime)));
}
}
if (Objects.equals(m_lowlinks.get(v), m_indices.get(v))) {
m_cycle = Lists.newArrayList();
T n;
do {
n = m_s.pop();
m_cycle.add(n);
} while (! n.equals(v));
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
public void push(String name, Object value) {
Map<String,Object> vars = threadLocalVariables.get();
if (vars == null) {
threadLocalVariables.set(vars = new HashMap<>()); //Generics.newHashMap());
}
Stack<Object> stack = (Stack<Object>) vars.get(name);
if (stack == null) {
vars.put(name, stack = new Stack<>());
}
stack.push(value);
}
代码示例来源:origin: k9mail/k-9
@Override
public void startMessage() throws MimeException {
if (stack.isEmpty()) {
stack.push(decryptedRootPart);
} else {
Part part = (Part) stack.peek();
Message innerMessage = new MimeMessage();
part.setBody(innerMessage);
stack.push(innerMessage);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
private GroovySourceAST getParentNode() {
Object currentNode = stack.pop();
Object parentNode = stack.peek();
stack.push(currentNode);
return (GroovySourceAST) parentNode;
}
内容来源于网络,如有侵权,请联系作者删除!