Tabnine Logo
Stack
Code IndexAdd Tabnine to your IDE (free)

How to use
Stack
in
java.util

Best Java code snippets using java.util.Stack (Showing top 20 results out of 32,724)

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: groovy/groovy-core

private GroovySourceAST getParentNode() {
  GroovySourceAST parentNode = null;
  GroovySourceAST currentNode = stack.pop();
  if (!stack.empty()) {
    parentNode = stack.peek();
  }
  stack.push(currentNode);
  return parentNode;
}
origin: jenkinsci/jenkins

private void detectedCycle(N q) throws CycleDetectedException {
  int i = path.indexOf(q);
  path.push(q);
  reactOnCycle(q, path.subList(i, path.size()));
}

origin: stanfordnlp/CoreNLP

 @Override
 void advance() {
  if (searchStack.isEmpty()) {
   next = null;
  } else {
   next = searchStack.pop();
  }
 }
};
origin: JetBrains/ideavim

private State currentState() {
 if (myStates.size() > 0) {
  return myStates.peek();
 }
 else {
  return myDefaultState;
 }
}
origin: org.apache.logging.log4j/log4j-api

@Test
public void testGetCurrentStackTrace() throws Exception {
  final Stack<Class<?>> classes = StackLocatorUtil.getCurrentStackTrace();
  final Stack<Class<?>> reversed = new Stack<>();
  reversed.ensureCapacity(classes.size());
  while (!classes.empty()) {
    reversed.push(classes.pop());
  }
  while (reversed.peek() != StackLocatorUtil.class) {
    reversed.pop();
  }
  reversed.pop(); // ReflectionUtil
  assertSame(StackLocatorUtilTest.class, reversed.pop());
}
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: 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: 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: 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 void validateRootExists(CaseInsensitiveString root, PipelineDependencyState pipelineDependencyState, Stack<CaseInsensitiveString> visiting) throws Exception {
  if (!pipelineDependencyState.hasPipeline(root)) {
    StringBuffer sb = new StringBuffer("Pipeline \"");
    sb.append(root);
    sb.append("\" does not exist.");
    visiting.pop();
    if (!visiting.empty()) {
      CaseInsensitiveString parent = visiting.peek();
      sb.append(" It is used from pipeline \"");
      sb.append(parent);
      sb.append("\".");
    }
    throw new Exception(sb.toString());
  }
}
origin: jenkinsci/jenkins

/**
 * Returns true if a project has a non-direct dependency to another project.
 * <p>
 * A non-direct dependency is a path of dependency "edge"s from the source to the destination,
 * where the length is greater than 1.
 */
public boolean hasIndirectDependencies(AbstractProject src, AbstractProject dst) {
  Set<AbstractProject> visited = new HashSet<AbstractProject>();
  Stack<AbstractProject> queue = new Stack<AbstractProject>();
  queue.addAll(getDownstream(src));
  queue.remove(dst);
  while(!queue.isEmpty()) {
    AbstractProject p = queue.pop();
    if(p==dst)
      return true;
    if(visited.add(p))
      queue.addAll(getDownstream(p));
  }
  return false;
}
origin: stanfordnlp/CoreNLP

public Object peek(String name) {
 Map<String,Object> vars = threadLocalVariables.get();
 if (vars == null) return null;
 Stack<Object> stack = (Stack<Object>) vars.get(name);
 if (stack == null || stack.isEmpty()) {
  return null;
 } else {
  return stack.peek();
 }
}
origin: commons-io/commons-io

@Test
public void testDataIntegrityWithBufferedReader() throws URISyntaxException, IOException {
  final File testFileIso = new File(this.getClass().getResource("/" + fileName).toURI());
  reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, buffSize, encoding);
  final Stack<String> lineStack = new Stack<>();
  bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(testFileIso), encoding));
  String line = null;
  // read all lines in normal order
  while ((line = bufferedReader.readLine()) != null) {
    lineStack.push(line);
  }
  // read in reverse order and compare with lines from stack
  while ((line = reversedLinesFileReader.readLine()) != null) {
    final String lineFromBufferedReader = lineStack.pop();
    assertEquals(lineFromBufferedReader, line);
  }
}
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: 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: jenkinsci/jenkins

public TableNestChecker() {
  elements.push(ALL_ALLOWED);
}
origin: apache/hive

/**
 * Pop the last signal
 */
public Signal signalPop() {
 if (!exec.signals.empty()) {
  return exec.signals.pop();
 }
 return null;
}

origin: stanfordnlp/CoreNLP

public FileSequentialCollectionIterator() {
 // log.info("Coll is " + coll);
 roots = coll.toArray();
 rootsIndex = 0;
 fileArrayStack = new Stack<>();
 fileArrayStackIndices = new Stack<>();
 if (roots.length > 0) {
  fileArrayStack.add(roots[rootsIndex]);
  fileArrayStackIndices.push(Integer.valueOf(0));
 }
 next = primeNextFile();
}
origin: jenkinsci/jenkins

public void moveUp() {
  pointers.pop();
}
java.utilStack

Javadoc

Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables users to pop to and push from the stack, including null objects. There is no limit to the size of the stack.

Most used methods

  • pop
    Removes the object at the top of this stack and returns that object as the value of this function.
  • push
    Pushes an item onto the top of this stack. This has exactly the same effect as:> addElement(item)
  • <init>
    Creates an empty Stack.
  • peek
    Looks at the object at the top of this stack without removing it from the stack.
  • isEmpty
  • size
  • empty
    Tests if this stack is empty.
  • clear
  • add
  • get
  • contains
  • elementAt
  • contains,
  • elementAt,
  • addAll,
  • remove,
  • lastElement,
  • iterator,
  • removeAllElements,
  • indexOf,
  • clone,
  • firstElement

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • String (java.lang)
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now