Example usage for java.util Deque removeFirst

List of usage examples for java.util Deque removeFirst

Introduction

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

Prototype

E removeFirst();

Source Link

Document

Retrieves and removes the first element of this deque.

Usage

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);//from w ww  .  j  av a2  s .  c o  m

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

        debug();
        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);
}