Stack empty - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Stack empty method.

This code example shows how to use the following methods:empty, peek, push
  private void closeIndent() { 
    indent--;
  } 
     
  private void printBeginEnvelope(String tag) {
    if (!compoundStack.empty()) {
      String s = compoundStack.peek();
      if ("struct".equals(s)) {
        putIndent(); 
        stream.print("<member>\n");
        addIndent(); 
        putIndent(); 
        stream.print("<name>"+tag+"</name>\n");
        putIndent(); 
        stream.print("<value>");
      } else if ("vector".equals(s)) {
        stream.print("<value>");
      } else if ("map".equals(s)) {
        stream.print("<value>");
      } 

8
CodeRank
This code example shows how to use the following methods:size, empty, peek, get
		screen.setParent( this );
		m_children.add( m_children.size( ), screen );
	} 
 
	private void sendPopEvent() { 
		if( m_screenStack.empty( ) )
		{ 
			return; 
		} 
 
		// Only pop and send events if the stack is not empty 
		int poppedToScreenHandle = getHandle( );
		if( m_screenStack.size( ) >= 2 )
		{ 
			// Get the previous screen before the last one. 
			poppedToScreenHandle = m_screenStack.get(m_screenStack.size()-2).getHandle();
		} 
 
		EventQueue.getDefault( ).postWidgetStackScreenPoppedEvent( 
				getHandle(), 

7
CodeRank
This code example shows how to use the following methods:empty, peek
            //java -Xrs for example will throw IllegalArgumentException 
        } 
    } 
 
    public void handle(Signal signal) {
        if (handlers.empty()) {
            handlerShell.shutdown();
            Runtime.getRuntime().halt(0);
        } 
        else { 
            SIGINT handler = (SIGINT)handlers.peek();
            handler.handleSIGINT();
        } 
    } 
 
    public static void push(SIGINT handler) {
        handlers.push(handler);
    } 
 
    public static void pop() { 
7
CodeRank
This code example shows how to use the following methods:empty, pop
      break; 
    case EXPECT_DATA:
      throw new InvalidXmlException("expected <DATA/>"); 
    case HANDLE_DATA:
      stanza.setValue(str);
      if (stanzaStack.empty()) {
        if (!name.equals("DATA")) {
          throw new InvalidXmlException("expected </DATA>"); 
        } 
        state = ParseState.EXPECT_RECORD;
        FSEditLogOp op = opCache.get(opCode);
        opCode = null;
        try { 
          op.decodeXml(stanza);
          stanza = null;
        } finally { 
          if (stanza != null) {
            System.err.println("fromXml error decoding opcode " + opCode +
                "\n" + stanza.toString());
            stanza = null;

7
CodeRank
This code example shows how to use the following methods:empty, peek, pop
    locationStack.pop();
    screenLocationStack.pop();
  } 
 
  public @Nullable Component component() { 
    if (componentStack.empty()) {
      return null; 
    } 
    Component c = componentStack.peek().get();
    // Make sure we don't return a component that has gone away. 
    if (c != null && isShowing(c)) {
      return c;
    } 
    componentStack.pop();
    locationStack.pop();
    screenLocationStack.pop();
    c = component();
    if (c != null) {
      location = locationStack.peek();
      locationOnScreen = screenLocationStack.peek();
7
CodeRank
This code example shows how to use the following methods:empty, peek, push
 
        Stack stack;
        // Get the stack that contains URIs for the specified prefix 
        if ((stack = (Stack) m_namespaces.get(prefix)) == null)
        { 
            m_namespaces.put(prefix, stack = new Stack());
        } 
 
        if (!stack.empty() && uri.equals(((MappingRecord)stack.peek()).m_uri))
        { 
            return false; 
        } 
        MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
        stack.push(map);
        m_nodeStack.push(map);
        return true; 
    } 
 
    /** 
     * Pop, or undeclare all namespace definitions that are currently 
7
CodeRank
This code example shows how to use the following methods:empty, push
 
    private JLabel jLabelStatus;
 
    private JProgressBar jProgressBar;
 
    private Stack<String> messages = new Stack<String>();
 
    private JPanelStatus() { 
	super(); 
 
	GridBagLayout jPanel1Layout = new GridBagLayout();
	jPanel1Layout.rowWeights = new double[] { 0.1 };
	jPanel1Layout.rowHeights = new int[] { 7 };
	jPanel1Layout.columnWeights = new double[] { 0.0, 0.1 };
	jPanel1Layout.columnWidths = new int[] { 787, 7 };
	setLayout(jPanel1Layout);
	setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); 
 
	jLabelStatus = new JLabel(defaultMessage);
	add(jLabelStatus, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,

6
CodeRank
This code example shows how to use the following methods:empty, peek, pop, push, size
    checkLargeStack(large, TEST_SIZE);
  } 
 
  /** tests empty and tries to get emptyStackException as desired. */ 
  public void testEmptyAndEmptyStackException() { 
    Stack<String> s = new Stack<String>();
    String item = "empty1";
    s.push(item);
    assertEquals(1, s.size());
    assertFalse(s.empty());
    assertEquals(s.pop(), item);
    checkEmptiness(s);
  } 
 
  /** Tests pop and peek. */ 
  public void testPopAndPeek() { 
    Stack<String> testStack = createStack();
    int x = testStack.size();
    Object item = testStack.peek();
    assertTrue(testStack.pop() == item);

7
CodeRank
This code example shows how to use the following methods:empty, pop
            } 
        } 
 
        public Tag pop() { 
            Tag result = top;
            if (tags.empty()) {
                isEmpty = true;
            } 
            else { 
                top = tags.pop();
            } 
            return result;
        } 
 
        public int size() { return tags.size() + (isEmpty ? 0 : 1); }
 
        public boolean isOpen() { return top.open; }
 
        public void close() { top.open = false; }
    } 
6
CodeRank
This code example shows how to use the following methods:empty, peek, push, get, size
            CSSMediaRuleImpl mr = new CSSMediaRuleImpl(
                CSSOMParser.this.getParentStyleSheet(),
                this.getParentRule(),
                ml);
            this.addLocator(mr);
            if (!this._nodeStack.empty()) {
                ((CSSRuleListImpl)this._nodeStack.peek()).add(mr);
            } 
 
            // Create the rule list 
            CSSRuleListImpl rules = new CSSRuleListImpl();
            mr.setRuleList(rules);
            this._nodeStack.push(mr);
            this._nodeStack.push(rules);
        } 
 
        public void endMedia(SACMediaList media) throws CSSException {
 
            // Pop the rule list and media rule nodes 
            this._nodeStack.pop();

6
CodeRank
empty Method Overview
Tests if this stack is empty.
See Code Examples for other Java 8 Stack Methods: