Example usage for java.util ArrayDeque addAll

List of usage examples for java.util ArrayDeque addAll

Introduction

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

Prototype

public 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:com.espertech.esper.core.start.EPPreparedExecuteMethod.java

private Collection<EventBean> getStreamFilterSnapshot(int streamNum,
        ContextPartitionSelector contextPartitionSelector) {
    final StreamSpecCompiled streamSpec = statementSpec.getStreamSpecs().get(streamNum);
    NamedWindowConsumerStreamSpec namedSpec = (NamedWindowConsumerStreamSpec) streamSpec;
    NamedWindowProcessor namedWindowProcessor = processors[streamNum];

    // handle the case of a single or matching agent instance
    NamedWindowProcessorInstance processorInstance = namedWindowProcessor
            .getProcessorInstance(agentInstanceContext);
    if (processorInstance != null) {
        return getStreamSnapshotInstance(streamNum, namedSpec, processorInstance);
    }/*from  www  .ja  v  a  2s.  c om*/

    // context partition runtime query
    Collection<Integer> contextPartitions;
    if (contextPartitionSelector == null || contextPartitionSelector instanceof ContextPartitionSelectorAll) {
        contextPartitions = namedWindowProcessor.getProcessorInstancesAll();
    } else {
        ContextManager contextManager = services.getContextManagementService()
                .getContextManager(namedWindowProcessor.getContextName());
        contextPartitions = contextManager.getAgentInstanceIds(contextPartitionSelector);
    }

    // collect events
    ArrayDeque<EventBean> events = new ArrayDeque<EventBean>();
    for (int agentInstanceId : contextPartitions) {
        processorInstance = namedWindowProcessor.getProcessorInstance(agentInstanceId);
        if (processorInstance != null) {
            Collection<EventBean> coll = processorInstance.getTailViewInstance().snapshot(filters[streamNum],
                    statementSpec.getAnnotations());
            events.addAll(coll);
        }
    }
    return events;
}

From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java

public void testAddAll() throws Exception {
    Object o1 = new Object();
    Object o2 = new Object();

    ArrayDeque<Object> deque = new ArrayDeque<>();
    assertTrue(deque.addAll(asList(o1, o2)));
    checkDequeSizeAndContent(deque, o1, o2);

    try {//from   w  w  w .  j a va 2  s. c o m
        deque = new ArrayDeque<>();
        deque.addAll(asList(o1, null, o2));
        fail();
    } catch (NullPointerException expected) {
    }
}

From source file:alluxio.underfs.swift.SwiftUnderFileSystem.java

/**
 * Lists the files or folders which match the given prefix using pagination.
 *
 * @param prefix the prefix to match//  w w  w.  j  a  va  2 s.  c o  m
 * @param recursive whether to do a recursive listing
 * @return a collection of the files or folders matching the prefix, or null if not found
 * @throws IOException if path is not accessible, e.g. network issues
 */
private Collection<DirectoryOrObject> listInternal(final String prefix, boolean recursive) throws IOException {
    // TODO(adit): UnderFileSystem interface should be changed to support pagination
    ArrayDeque<DirectoryOrObject> results = new ArrayDeque<>();
    Container container = mAccount.getContainer(mContainerName);
    PaginationMap paginationMap = container.getPaginationMap(prefix, LISTING_LENGTH);
    for (int page = 0; page < paginationMap.getNumberOfPages(); page++) {
        if (!recursive) {
            // If not recursive, use delimiter to limit results fetched
            results.addAll(container.listDirectory(paginationMap.getPrefix(), PATH_SEPARATOR_CHAR,
                    paginationMap.getMarker(page), paginationMap.getPageSize()));
        } else {
            results.addAll(container.list(paginationMap, page));
        }
    }
    return results;
}

From source file:fr.moribus.imageonmap.migration.V3Migrator.java

private void mergeMapData() {
    PluginLogger.info(I.t("Merging map data..."));

    ArrayDeque<OldSavedMap> remainingMaps = new ArrayDeque<>();
    ArrayDeque<OldSavedPoster> remainingPosters = new ArrayDeque<>();

    ArrayDeque<Short> missingMapIds = new ArrayDeque<>();

    UUID playerUUID;/*  w w w .  j ava2 s . c  o m*/
    OldSavedMap map;
    while (!mapsToMigrate.isEmpty()) {
        map = mapsToMigrate.pop();
        playerUUID = usersUUIDs.get(map.getUserName());
        if (playerUUID == null) {
            remainingMaps.add(map);
        } else if (!map.isMapValid()) {
            missingMapIds.add(map.getMapId());
        } else {
            MapManager.insertMap(map.toImageMap(playerUUID));
        }
    }
    mapsToMigrate.addAll(remainingMaps);

    OldSavedPoster poster;
    while (!postersToMigrate.isEmpty()) {
        poster = postersToMigrate.pop();
        playerUUID = usersUUIDs.get(poster.getUserName());
        if (playerUUID == null) {
            remainingPosters.add(poster);
        } else if (!poster.isMapValid()) {
            missingMapIds.addAll(Arrays.asList(ArrayUtils.toObject(poster.getMapsIds())));
        } else {
            MapManager.insertMap(poster.toImageMap(playerUUID));
        }
    }
    postersToMigrate.addAll(remainingPosters);

    if (!missingMapIds.isEmpty()) {
        PluginLogger.warning(I.tn("{0} registered minecraft map is missing from the save.",
                "{0} registered minecraft maps are missing from the save.", missingMapIds.size()));
        PluginLogger.warning(I.t(
                "These maps will not be migrated, but this could mean the save has been altered or corrupted."));
        PluginLogger
                .warning(I.t("The following maps are missing : {0} ", StringUtils.join(missingMapIds, ',')));
    }
}