Example usage for java.util Deque addAll

List of usage examples for java.util Deque addAll

Introduction

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

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection at the end of this deque, as if by calling #addLast on each one, in the order that they are returned by the collection's iterator.

Usage

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

@Override
protected void updateEnabled() {
    if (pageBody == null || pageBody.isDisposed()) {
        return;/*from   w w  w. ja  v a  2 s.  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(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:uniol.apt.analysis.synthesize.separation.KBoundedSeparation.java

private void generateAllRegions(int k) {
    assert k >= 1;

    Set<Bag<State>> known = new HashSet<>();
    Deque<Bag<State>> todo = new LinkedList<>();
    addExcitationAndSwitchingRegions(known);
    todo.addAll(known);

    while (!todo.isEmpty()) {
        InterrupterRegistry.throwIfInterruptRequestedForCurrentThread();
        Bag<State> r = todo.removeFirst();

        debug();/*from  ww  w . j  a va 2 s  . c om*/
        debugFormat("Examining %s", r);

        Pair<Event, Integer> event = findEventWithNonConstantGradient(r);
        if (event == null) {
            debug("It is a region!");
            regions.add(convertToRegion(r));
            continue;
        }

        // Expand (= add entries) to the multiset so that it becomes "more region-like".
        // To do this, we either want to go towards a region with gradient(event) <= g or
        // gradient(event) > g. These two cases follow.

        Bag<State> r1 = expandBelowOrEqual(r, event.getFirst(), event.getSecond());
        debugFormat("for gradient(%s) <= %d, new result is %s", event.getFirst(), event.getSecond(), r1);
        if (shouldExplore(r1, k) && known.add(r1))
            todo.add(r1);
        else
            debug("...which should not be explored");

        Bag<State> r2 = expandAboveOrEqual(r, event.getFirst(), event.getSecond() + 1);
        debugFormat("for gradient(%s) >= %d, new result is %s", event.getFirst(), event.getSecond() + 1, r2);
        if (shouldExplore(r2, k) && known.add(r2))
            todo.add(r2);
        else
            debug("...which should not be explored");
    }

    debugFormat("Found the following regions: %s", regions);
}