Example usage for java.util ArrayDeque add

List of usage examples for java.util ArrayDeque add

Introduction

In this page you can find the example usage for java.util ArrayDeque add.

Prototype

public boolean add(E e) 

Source Link

Document

Inserts the specified element at the end of this deque.

Usage

From source file:com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration.java

@Override
public String saveToString() {
    yamlOptions.setIndent(options().indent());
    yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
    yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

    // String header = buildHeader(); - CommentedConfiguration
    String dump = yaml.dump(getValues(false));

    if (dump.equals(BLANK_CONFIG)) {
        dump = "";
    }//from   www  .j av a2s  .  co m

    // Begin CommentedConfiguration
    StringBuilder builder = new StringBuilder();

    String[] lines = dump.split("\n");
    ArrayDeque<String> queue = new ArrayDeque<String>();
    for (String string : lines) {
        queue.add(string);
    }

    int i = 0;
    while (queue.size() > 0) {
        if (comments.containsKey(i)) {
            builder.append(comments.get(i));

            // Handle subsequent comments
            int b = i;
            while (true) {
                b++;
                if (comments.containsKey(b)) {
                    builder.append('\n');
                    builder.append(comments.get(b));
                } else {
                    break;
                }
            }
            builder.append('\n');
            i = b;
        }

        builder.append(queue.getFirst());
        builder.append('\n');
        queue.pop();
        i++;
    }
    // End CommentedConfiguration

    return builder.toString();
}

From source file:androidx.navigation.NavDeepLinkBuilder.java

private void fillInIntent() {
    NavDestination node = null;//from   w w  w.java2 s.  c  om
    ArrayDeque<NavDestination> possibleDestinations = new ArrayDeque<>();
    possibleDestinations.add(mGraph);
    while (!possibleDestinations.isEmpty() && node == null) {
        NavDestination destination = possibleDestinations.poll();
        if (destination.getId() == mDestId) {
            node = destination;
        } else if (destination instanceof NavGraph) {
            for (NavDestination child : (NavGraph) destination) {
                possibleDestinations.add(child);
            }
        }
    }
    if (node == null) {
        final String dest = NavDestination.getDisplayName(mContext, mDestId);
        throw new IllegalArgumentException(
                "navigation destination " + dest + " is unknown to this NavController");
    }
    mIntent.putExtra(NavController.KEY_DEEP_LINK_IDS, node.buildDeepLinkIds());
}

From source file:com.heliosdecompiler.helios.gui.controller.FileTreeController.java

private void handleChanges(State startingState, List<TreeNode> changes) {
    ArrayDeque<State> check = new ArrayDeque<>();
    check.add(startingState);
    while (!check.isEmpty()) {
        State next = check.pop();
        TreeNode match = Utils.find(next.needle, next.haystack);
        if (match != null) {
            for (TreeNode current : next.needle.getChildren()) {
                check.add(new State(current, match.getChildren()));
            }//from   w w w.j  a  v  a  2 s . co  m
        } else {
            changes.add(next.needle);
        }
    }
}

From source file:com.espertech.esper.view.std.GroupByViewReclaimAged.java

private void sweep(long currentTime) {
    ArrayDeque<Object> removed = new ArrayDeque<Object>();
    for (Map.Entry<Object, GroupByViewAgedEntry> entry : subViewsPerKey.entrySet()) {
        long age = currentTime - entry.getValue().getLastUpdateTime();
        if (age > reclaimMaxAge) {
            removed.add(entry.getKey());
        }/*  www.  j  av  a 2  s.  c  om*/
    }

    for (Object key : removed) {
        GroupByViewAgedEntry entry = subViewsPerKey.remove(key);
        Object subviewHolder = entry.getSubviewHolder();
        if (subviewHolder instanceof List) {
            List<View> subviews = (List<View>) subviewHolder;
            for (View view : subviews) {
                removeSubview(view);
            }
        } else if (subviewHolder instanceof View) {
            removeSubview((View) subviewHolder);
        }
    }
}

From source file:org.apache.gobblin.ingestion.google.webmaster.GoogleWebmasterDataFetcherImpl.java

/**
 * Due to the limitation of the API, we can get a maximum of 5000 rows at a time. Another limitation is that, results are sorted by click count descending. If two rows have the same click count, they are sorted in an arbitrary way. (Read more at https://developers.google.com/webmaster-tools/v3/searchanalytics). So we try to get all pages by partitions, if a partition has 5000 rows returned. We try partition current partition into more granular levels.
 *
 *//*  w  ww  .j  a  v a2 s.c o  m*/
@Override
public Collection<ProducerJob> getAllPages(String startDate, String endDate, String country, int rowLimit)
        throws IOException {
    log.info("Requested row limit: " + rowLimit);
    if (!_jobs.isEmpty()) {
        log.info("Service got hot started.");
        return _jobs;
    }
    ApiDimensionFilter countryFilter = GoogleWebmasterFilter.countryEqFilter(country);

    List<GoogleWebmasterFilter.Dimension> requestedDimensions = new ArrayList<>();
    requestedDimensions.add(GoogleWebmasterFilter.Dimension.PAGE);
    int expectedSize = -1;
    if (rowLimit >= GoogleWebmasterClient.API_ROW_LIMIT) {
        //expected size only makes sense when the data set size is larger than GoogleWebmasterClient.API_ROW_LIMIT
        expectedSize = getPagesSize(startDate, endDate, country, requestedDimensions,
                Arrays.asList(countryFilter));
        log.info(String.format("Expected number of pages is %d for market-%s from %s to %s", expectedSize,
                GoogleWebmasterFilter.countryFilterToString(countryFilter), startDate, endDate));
    }

    Queue<Pair<String, FilterOperator>> jobs = new ArrayDeque<>();
    jobs.add(Pair.of(_siteProperty, FilterOperator.CONTAINS));

    Collection<String> allPages = getPages(startDate, endDate, requestedDimensions, countryFilter, jobs,
            Math.min(rowLimit, GoogleWebmasterClient.API_ROW_LIMIT));
    int actualSize = allPages.size();
    log.info(String.format("A total of %d pages fetched for property %s at country-%s from %s to %s",
            actualSize, _siteProperty, country, startDate, endDate));

    if (expectedSize != -1 && actualSize != expectedSize) {
        log.warn(String.format("Expected page size is %d, but only able to get %d", expectedSize, actualSize));
    }

    ArrayDeque<ProducerJob> producerJobs = new ArrayDeque<>(actualSize);
    for (String page : allPages) {
        producerJobs.add(new SimpleProducerJob(page, startDate, endDate));
    }
    return producerJobs;
}

From source file:com.espertech.esper.epl.expression.ExprTimePeriodImpl.java

public void validate(ExprValidationContext validationContext) throws ExprValidationException {
    evaluators = ExprNodeUtility.getEvaluators(this.getChildNodes());
    for (ExprNode childNode : this.getChildNodes()) {
        validate(childNode);//from www. j  av  a2s .com
    }

    ArrayDeque<TimePeriodAdder> list = new ArrayDeque<TimePeriodAdder>();
    if (hasYear) {
        list.add(new TimePeriodAdderYear());
    }
    if (hasMonth) {
        list.add(new TimePeriodAdderMonth());
    }
    if (hasWeek) {
        list.add(new TimePeriodAdderWeek());
    }
    if (hasDay) {
        list.add(new TimePeriodAdderDay());
    }
    if (hasHour) {
        list.add(new TimePeriodAdderHour());
    }
    if (hasMinute) {
        list.add(new TimePeriodAdderMinute());
    }
    if (hasSecond) {
        list.add(new TimePeriodAdderSecond());
    }
    if (hasMillisecond) {
        list.add(new TimePeriodAdderMSec());
    }
    adders = list.toArray(new TimePeriodAdder[list.size()]);
}

From source file:com.espertech.esper.epl.agg.service.AggSvcGroupByReclaimAgedImpl.java

private void sweep(long currentTime, long currentMaxAge) {
    ArrayDeque<Object> removed = new ArrayDeque<Object>();
    for (Map.Entry<Object, AggregationMethodRowAged> entry : aggregatorsPerGroup.entrySet()) {
        long age = currentTime - entry.getValue().getLastUpdateTime();
        if (age > currentMaxAge) {
            removed.add(entry.getKey());
        }/*from  w w  w  .java  2 s  . c  om*/
    }

    for (Object key : removed) {
        aggregatorsPerGroup.remove(key);
        internalHandleRemoved(key);
        removedCallback.removed(key);
    }
}

From source file:com.espertech.esper.epl.agg.AggSvcGroupByReclaimAged.java

private void sweep(long currentTime, long currentMaxAge) {
    ArrayDeque<MultiKeyUntyped> removed = new ArrayDeque<MultiKeyUntyped>();
    for (Map.Entry<MultiKeyUntyped, AggregationMethodRowAged> entry : aggregatorsPerGroup.entrySet()) {
        long age = currentTime - entry.getValue().getLastUpdateTime();
        if (age > currentMaxAge) {
            removed.add(entry.getKey());
        }// w  w  w  .  ja  va  2s.c om
    }

    for (MultiKeyUntyped key : removed) {
        aggregatorsPerGroup.remove(key);
    }
}

From source file:com.espertech.esper.event.vaevent.VAERevisionProcessorMerge.java

public Collection<EventBean> getSnapshot(EPStatementAgentInstanceHandle createWindowStmtHandle,
        Viewable parent) {// w  ww . jav a  2s .c om
    createWindowStmtHandle.getStatementAgentInstanceLock().acquireReadLock();
    try {
        Iterator<EventBean> it = parent.iterator();
        if (!it.hasNext()) {
            return Collections.EMPTY_LIST;
        }
        ArrayDeque<EventBean> list = new ArrayDeque<EventBean>();
        while (it.hasNext()) {
            RevisionEventBeanMerge fullRevision = (RevisionEventBeanMerge) it.next();
            Object key = fullRevision.getKey();
            RevisionStateMerge state = statePerKey.get(key);
            list.add(state.getLastEvent());
        }
        return list;
    } finally {
        createWindowStmtHandle.getStatementAgentInstanceLock().releaseReadLock();
    }
}

From source file:com.espertech.esper.event.vaevent.VAERevisionProcessorDeclared.java

public Collection<EventBean> getSnapshot(EPStatementAgentInstanceHandle createWindowStmtHandle,
        Viewable parent) {/*from   w w  w. ja  va2 s.  co m*/
    createWindowStmtHandle.getStatementAgentInstanceLock().acquireReadLock();
    try {
        Iterator<EventBean> it = parent.iterator();
        if (!it.hasNext()) {
            return Collections.EMPTY_LIST;
        }
        ArrayDeque<EventBean> list = new ArrayDeque<EventBean>();
        while (it.hasNext()) {
            RevisionEventBeanDeclared fullRevision = (RevisionEventBeanDeclared) it.next();
            Object key = fullRevision.getKey();
            RevisionStateDeclared state = statePerKey.get(key);
            list.add(state.getLastEvent());
        }
        return list;
    } finally {
        createWindowStmtHandle.getStatementAgentInstanceLock().releaseReadLock();
    }
}