Search in sources :

Example 21 with EmptyStackException

use of java.util.EmptyStackException in project CtCI-6th-Edition by careercup.

the class Stack method pop.

public int pop() {
    if (top == null)
        throw new EmptyStackException();
    Node t = top;
    top = top.below;
    size--;
    return t.value;
}
Also used : EmptyStackException(java.util.EmptyStackException)

Example 22 with EmptyStackException

use of java.util.EmptyStackException in project CtCI-6th-Edition by careercup.

the class SetOfStacks method pop.

public int pop() {
    Stack last = getLastStack();
    if (last == null)
        throw new EmptyStackException();
    int v = last.pop();
    if (last.size == 0) {
        stacks.remove(stacks.size() - 1);
    }
    return v;
}
Also used : EmptyStackException(java.util.EmptyStackException)

Example 23 with EmptyStackException

use of java.util.EmptyStackException in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method startContexts.

protected void startContexts() {
    withModule((def, parents) -> {
        try {
            final ApplicationContext context = getApplicationContext(def.getName());
            try {
                final Runnable runnable = context.getBean("moduleStartup", Runnable.class);
                log.info("Starting module [{}]", def.getName());
                runnable.run();
            } catch (final BeansException e) {
                log.warn("Ignore", e);
            }
        } catch (final EmptyStackException e) {
            log.warn("The root context is already loaded, so ignore the exception", e);
        }
    });
}
Also used : EmptyStackException(java.util.EmptyStackException) ResourceApplicationContext(com.cloud.spring.module.context.ResourceApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) BeansException(org.springframework.beans.BeansException)

Example 24 with EmptyStackException

use of java.util.EmptyStackException in project cosmic by MissionCriticalCloud.

the class DefaultModuleDefinitionSet method loadContexts.

protected void loadContexts() {
    withModule((def, parents) -> {
        try {
            final String applicationContextName = parents.peek().getName();
            log.debug("Loading application context: " + applicationContextName);
            final ApplicationContext parent = getApplicationContext(applicationContextName);
            loadContext(def, parent);
        } catch (final EmptyStackException e) {
            log.warn("The root context is already loaded, so ignore the exception", e);
        }
    });
}
Also used : EmptyStackException(java.util.EmptyStackException) ResourceApplicationContext(com.cloud.spring.module.context.ResourceApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext)

Example 25 with EmptyStackException

use of java.util.EmptyStackException in project robovm by robovm.

the class NamespaceSupportTest method testReset.

public void testReset() {
    int count;
    ns = new NamespaceSupport();
    count = countPrefixes();
    ns.pushContext();
    ns.declarePrefix("dc", "http://www.purl.org/dc#");
    assertEquals("Test 1: Incorrect prefix count;", count + 1, countPrefixes());
    ns.reset();
    assertEquals("Test 2: Incorrect prefix count;", count, countPrefixes());
    // Check that only one context has been created by reset().
    try {
        ns.popContext();
        fail("Test 3: EmptyStackException expected.");
    } catch (EmptyStackException e) {
    // Expected.
    }
}
Also used : EmptyStackException(java.util.EmptyStackException) NamespaceSupport(org.xml.sax.helpers.NamespaceSupport)

Aggregations

EmptyStackException (java.util.EmptyStackException)47 Stack (java.util.Stack)13 Test (org.junit.Test)6 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)5 Callable (java.util.concurrent.Callable)5 NamespaceSupport (org.xml.sax.helpers.NamespaceSupport)5 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)3 IOException (java.io.IOException)3 ResourceApplicationContext (com.cloud.spring.module.context.ResourceApplicationContext)2 ConfigCompileException (com.laytonsmith.core.exceptions.ConfigCompileException)2 ArrayList (java.util.ArrayList)2 SystemException (org.omg.CORBA.SystemException)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ActionControl (com.arjuna.ArjunaOTS.ActionControl)1 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)1 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 TabHeader (com.jsql.view.swing.tab.TabHeader)1 FileOptions (com.laytonsmith.core.compiler.FileOptions)1 KeywordList (com.laytonsmith.core.compiler.KeywordList)1 CDecimal (com.laytonsmith.core.constructs.CDecimal)1