Example usage for java.util Deque isEmpty

List of usage examples for java.util Deque isEmpty

Introduction

In this page you can find the example usage for java.util Deque isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this collection contains no elements.

Usage

From source file:org.jboss.as.test.integration.logging.profiles.CommonsLoggingServiceActivator.java

private String getFirstValue(final Map<String, Deque<String>> params, final String key) {
    if (params.containsKey(key)) {
        final Deque<String> values = params.get(key);
        if (values != null && !values.isEmpty()) {
            return values.getFirst();
        }//from  w ww.  jav  a2 s  .co m
    }
    return null;
}

From source file:org.apache.tajo.engine.planner.global.ParallelExecutionQueue.java

@Override
public synchronized ExecutionBlock[] next(ExecutionBlockId doneNow) {
    executed.add(doneNow);//from   w  w  w.j a v a2 s.  c  om

    int remaining = 0;
    for (Deque<ExecutionBlock> queue : executable) {
        if (!queue.isEmpty() && isExecutableNow(queue.peekLast())) {
            LOG.info("Next executable block " + queue.peekLast());
            return new ExecutionBlock[] { queue.removeLast() };
        }
        remaining += queue.size();
    }
    return remaining > 0 ? new ExecutionBlock[0] : null;
}

From source file:com.espertech.esper.event.EventTypeUtility.java

public static EventPropertyDescriptor getNestablePropertyDescriptor(EventType target, Deque<Property> stack) {

    Property topProperty = stack.removeFirst();
    if (stack.isEmpty()) {
        return target.getPropertyDescriptor(((PropertyBase) topProperty).getPropertyNameAtomic());
    }/*from w w w  . j  a va 2 s. c o m*/

    if (!(topProperty instanceof SimpleProperty)) {
        return null;
    }
    SimpleProperty simple = (SimpleProperty) topProperty;

    FragmentEventType fragmentEventType = target.getFragmentType(simple.getPropertyNameAtomic());
    if (fragmentEventType == null || fragmentEventType.getFragmentType() == null) {
        return null;
    }
    return getNestablePropertyDescriptor(fragmentEventType.getFragmentType(), stack);
}

From source file:org.seedstack.spring.internal.SpringTransactionStatusLink.java

TransactionStatus pop() {
    Deque<TransactionStatus> transactionStatuses = perThreadObjectContainer.get();
    TransactionStatus transactionStatus = transactionStatuses.pop();
    if (transactionStatuses.isEmpty()) {
        perThreadObjectContainer.remove();
    }//from  w w w.  j a  va  2s.c  o m
    return transactionStatus;
}

From source file:org.structnetalign.merge.DistanceClusterer.java

/**
 *
 * @param graph/*from w ww .j a  v  a  2s . c o m*/
 * @param roots
 * @return For each root, the set of other roots that are easily reachable, including the parent root
 */
public final Map<V, Set<V>> transform(Graph<V, E> graph, Collection<V> roots) {

    Map<V, Set<V>> reachableMap = new HashMap<V, Set<V>>();

    for (V root : roots) {

        Set<V> reachable = new HashSet<>();
        HashSet<V> unvisited = new HashSet<V>(graph.getVertices());

        // a map from every vertex to the edge used to get to it
        // works because only visit a vertex once
        HashMap<V, E> edgesTaken = new HashMap<V, E>();

        Deque<V> queue = new LinkedList<V>();
        queue.add(root);
        reachable.add(root);

        while (!queue.isEmpty()) {

            V vertex = queue.remove();
            E edge = edgesTaken.get(vertex);
            unvisited.remove(vertex);

            // stop traversing if we're too far
            if (!isWithinRange(root, vertex))
                continue;

            reachable.add(vertex); // not that this is AFTER the within-range check

            if (edge != null)
                visit(vertex, edge); // this is the ONLY place where we "officially" VISIT a vertex

            Collection<V> neighbors = graph.getNeighbors(vertex);
            for (V neighbor : neighbors) {
                if (unvisited.contains(neighbor)) {
                    queue.add(neighbor);
                    E edgeToNeighbor = graph.findEdge(vertex, neighbor);
                    edgesTaken.put(neighbor, edgeToNeighbor);
                }
            }

            unvisit(vertex, edge); // this is the ONLY place where we "officially" UNVISIT a vertex

        }

        reachableMap.put(root, reachable);

    }

    return reachableMap;
}

From source file:eu.openanalytics.rsb.rservi.CircularRServiUriSelector.java

public URI getUriForApplication(final String applicationName) {
    if ((circularApplicationUris == null) || (circularApplicationUris.isEmpty())) {
        return configuration.getDefaultRserviPoolUri();
    }//from   w w w  .ja  v  a 2 s  .  c o m

    final Deque<URI> applicationRserviPoolUris = circularApplicationUris.get(applicationName);

    final boolean applicationHasNoSpecificUris = applicationRserviPoolUris == null
            || applicationRserviPoolUris.isEmpty();

    return applicationHasNoSpecificUris ? configuration.getDefaultRserviPoolUri()
            : getCircular(applicationRserviPoolUris);
}

From source file:com.core.controller.AlgoritmoController.java

public static String busquedaProfundidad(Grafo g, String inicio, String fin) {
    Deque<String> pila = new ArrayDeque<>();
    Deque<String> padresPila = new ArrayDeque<>();
    List<String> explorados = new ArrayList<>();
    List<String> padresExplorados = new ArrayList<>();
    String nodoActual, nodoPadre;
    String result = "Algoritmo de Busqueda Primero en Profundidad";
    result += "\nCantidad de nodos: " + g.getNodos().size();
    result += "\nCantidad de aristas: " + g.getAristas().size();
    pila.push(inicio);//www .j  av  a 2  s .com
    padresPila.push("#");
    while (true) {
        result += "\nPila: " + Arrays.toString(pila.toArray());
        if (pila.isEmpty()) {
            result += "\nNo se encontro el nodo destino";
            break;
        }
        nodoActual = pila.pop();
        nodoPadre = padresPila.pop();
        explorados.add(nodoActual);
        padresExplorados.add(nodoPadre);
        if (nodoActual.equals(fin)) {
            result += "\nNodo destino alcanzado"; //Mostrar camino
            String nodo = nodoActual;
            String secuenciaResultado = "";
            while (nodo != "#") {
                secuenciaResultado = nodo + " " + secuenciaResultado;
                nodo = padresExplorados.get(explorados.indexOf(nodo));
            }
            result += "\nCamino solucion: " + secuenciaResultado;
            break;
        }
        List<String> vecinos = g.nodosVecinos(nodoActual);
        for (int i = vecinos.size() - 1; i >= 0; i--) {
            String a = vecinos.get(i);
            if (!explorados.contains(a)) {
                if (pila.contains(a)) {
                    pila.remove(a);
                    padresPila.remove(nodoActual);
                }
                pila.push(a);
                padresPila.push(nodoActual);
            }
        }
    }
    return result;
}

From source file:org.lunarray.model.descriptor.builder.annotation.resolver.entity.def.DefaultEntityResolver.java

/** {@inheritDoc} */
@Override/*from  w  w  w  .ja  va  2  s  . c o m*/
public DescribedEntity<?> resolveEntity(final Class<?> entityType) {
    DefaultEntityResolver.LOGGER.debug("Resolving entity {}", entityType);
    Validate.notNull(entityType, "Entity type may not be null.");
    @SuppressWarnings("unchecked")
    final EntityBuilder<?> builder = DescribedEntity.createBuilder().entityType((Class<Object>) entityType);
    final List<Class<?>> hierarchy = new LinkedList<Class<?>>();
    if (this.searchHierarchyResolver) {
        final Deque<Class<?>> types = new LinkedList<Class<?>>();
        final Set<Class<?>> processed = new HashSet<Class<?>>();
        types.add(entityType);
        while (!types.isEmpty()) {
            final Class<?> next = types.pop();
            hierarchy.add(next);
            final Class<?> superType = next.getSuperclass();
            if (!CheckUtil.isNull(superType) && !processed.contains(superType)) {
                types.add(superType);
            }
            for (final Class<?> interfaceType : next.getInterfaces()) {
                if (!processed.contains(interfaceType)) {
                    types.add(interfaceType);
                }
            }
            processed.add(next);
        }
    } else {
        hierarchy.add(entityType);
    }
    for (final Class<?> type : hierarchy) {
        for (final Annotation a : type.getAnnotations()) {
            builder.addAnnotation(a);
        }
    }
    final DescribedEntity<?> result = builder.build();
    DefaultEntityResolver.LOGGER.debug("Resolved entity {} for type {}", result, entityType);
    return result;
}

From source file:org.polymap.rhei.form.batik.BatikFormContainer.java

@Override
protected void updateEnabled() {
    if (pageBody == null || pageBody.isDisposed()) {
        return;/*from  w ww  . ja va2s. co m*/
    }

    Deque<Control> deque = new LinkedList(Collections.singleton(pageBody));
    while (!deque.isEmpty()) {
        Control control = deque.pop();

        String variant = (String) control.getData(RWT.CUSTOM_VARIANT);
        log.debug("VARIANT: " + variant + " (" + control.getClass().getSimpleName() + ")");

        // form fields
        if (variant == null || variant.equals(CSS_FORMFIELD) || variant.equals(CSS_FORMFIELD_DISABLED)
                || variant.equals(BaseFieldComposite.CUSTOM_VARIANT_VALUE)) {
            UIUtils.setVariant(control, enabled ? CSS_FORMFIELD : CSS_FORMFIELD_DISABLED);
        }
        // form
        else if (variant.equals(CSS_FORM) || variant.equals(CSS_FORM_DISABLED)) {
            UIUtils.setVariant(control, enabled ? CSS_FORM : CSS_FORM_DISABLED);
        }

        //            // labeler Label
        //            String labelVariant = (String)control.getData( WidgetUtil.CUSTOM_VARIANT );
        //            if (control instanceof Label
        //                    && (labelVariant.equals( CSS_FORMFIELD ) || labelVariant.equals( CSS_FORMFIELD_DISABLED ))) {
        //                control.setFont( enabled 
        //                        ? JFaceResources.getFontRegistry().get( JFaceResources.DEFAULT_FONT )
        //                        : JFaceResources.getFontRegistry().getBold( JFaceResources.DEFAULT_FONT ) );
        //
        //                if (!enabled) {
        //                    control.setBackground( Graphics.getColor( 0xED, 0xEF, 0xF1 ) );
        //                }
        //            }
        // Composite
        if (control instanceof Composite) {
            control.setEnabled(enabled);

            deque.addAll(Arrays.asList(((Composite) control).getChildren()));
        }
        variant = (String) control.getData(RWT.CUSTOM_VARIANT);
        log.debug("      -> " + variant + " (" + control.getClass().getSimpleName() + ")");
    }
}

From source file:org.polymap.rhei.form.batik.BatikFilterContainer.java

@Override
protected void updateEnabled() {
    if (pageBody == null || pageBody.isDisposed()) {
        return;//  www.j a  va2s  . c o  m
    }

    Deque<Control> deque = new LinkedList(Collections.singleton(pageBody));
    while (!deque.isEmpty()) {
        Control control = deque.pop();

        String variant = (String) control.getData(RWT.CUSTOM_VARIANT);
        log.debug("VARIANT: " + variant + " (" + control.getClass().getSimpleName() + ")");

        // form fields
        if (variant == null || variant.equals(BatikFormContainer.CSS_FORMFIELD)
                || variant.equals(BatikFormContainer.CSS_FORMFIELD_DISABLED)
                || variant.equals(BaseFieldComposite.CUSTOM_VARIANT_VALUE)) {
            UIUtils.setVariant(control,
                    enabled ? BatikFormContainer.CSS_FORMFIELD : BatikFormContainer.CSS_FORMFIELD_DISABLED);
        }
        // form
        else if (variant.equals(BatikFormContainer.CSS_FORM)
                || variant.equals(BatikFormContainer.CSS_FORM_DISABLED)) {
            UIUtils.setVariant(control,
                    enabled ? BatikFormContainer.CSS_FORM : BatikFormContainer.CSS_FORM_DISABLED);
        }

        //            // labeler Label
        //            String labelVariant = (String)control.getData( WidgetUtil.CUSTOM_VARIANT );
        //            if (control instanceof Label
        //                    && (labelVariant.equals( CSS_FORMFIELD ) || labelVariant.equals( CSS_FORMFIELD_DISABLED ))) {
        //                control.setFont( enabled 
        //                        ? JFaceResources.getFontRegistry().get( JFaceResources.DEFAULT_FONT )
        //                        : JFaceResources.getFontRegistry().getBold( JFaceResources.DEFAULT_FONT ) );
        //
        //                if (!enabled) {
        //                    control.setBackground( Graphics.getColor( 0xED, 0xEF, 0xF1 ) );
        //                }
        //            }
        // Composite
        if (control instanceof Composite) {
            control.setEnabled(enabled);

            deque.addAll(Arrays.asList(((Composite) control).getChildren()));
        }
        variant = (String) control.getData(RWT.CUSTOM_VARIANT);
        log.debug("      -> " + variant + " (" + control.getClass().getSimpleName() + ")");
    }
}