Example usage for java.util LinkedList add

List of usage examples for java.util LinkedList add

Introduction

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

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:eu.stratosphere.test.operators.JoinITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {

    LinkedList<Configuration> tConfigs = new LinkedList<Configuration>();

    String[] localStrategies = { PactCompiler.HINT_LOCAL_STRATEGY_SORT_BOTH_MERGE,
            PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST,
            PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND };

    String[] shipStrategies = { PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_HASH, "BROADCAST_FIRST",
            "BROADCAST_SECOND" };

    for (String localStrategy : localStrategies) {
        for (String shipStrategy : shipStrategies) {

            Configuration config = new Configuration();
            config.setString("MatchTest#LocalStrategy", localStrategy);
            config.setString("MatchTest#ShipStrategy", shipStrategy);
            config.setInteger("MatchTest#NoSubtasks", 4);

            tConfigs.add(config);
        }//w  w w.j ava  2  s.  c o  m
    }

    return toParameterList(tConfigs);
}

From source file:com.example.app.support.service.AppUtil.java

/**
 * Get a valid source component from the component path.  This is similar to
 * {@link ApplicationRegistry#getValidSourceComponent(Component)} but is able to find the source component even
 * when a pesky dialog is in the in way as long as the dialog had {@link #recordDialogsAncestorComponent(Dialog, Component)}
 * call on it.//  w w  w .ja v a  2 s  .  com
 *
 * @param component the component to start the search on
 *
 * @return a valid source component that has an ApplicationFunction annotation.
 *
 * @throws IllegalArgumentException if a valid source component could not be found.
 */
@Nonnull
public static Component getValidSourceComponentAcrossDialogs(Component component) {
    LinkedList<Component> path = new LinkedList<>();
    do {
        path.add(component);

        if (component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY) instanceof Component)
            component = (Component) component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY);
        else
            component = component.getParent();

    } while (component != null);

    final ListIterator<Component> listIterator = path.listIterator(path.size());
    while (listIterator.hasPrevious()) {
        final Component previous = listIterator.previous();
        if (previous.getClass().isAnnotationPresent(ApplicationFunction.class))
            return previous;
    }
    throw new IllegalArgumentException("Component path does not contain an application function.");
}

From source file:com.github.dozermapper.core.util.MappingUtils.java

@SuppressWarnings("unchecked")
public static List<Class<?>> getInterfaceHierarchy(Class<?> srcClass, BeanContainer beanContainer) {
    final List<Class<?>> result = new LinkedList<>();
    Class<?> realClass = getRealClass(srcClass, beanContainer);

    final LinkedList<Class> interfacesToProcess = new LinkedList<>();

    Class[] interfaces = realClass.getInterfaces();

    interfacesToProcess.addAll(Arrays.asList(interfaces));

    while (!interfacesToProcess.isEmpty()) {
        Class<?> iface = interfacesToProcess.remove();
        if (!result.contains(iface)) {
            result.add(iface);/*from   w w w.  j  a  va  2s.c  om*/
            for (Class subiface : iface.getInterfaces()) {
                // if we haven't processed this interface yet then add it to be processed
                if (!result.contains(subiface)) {
                    interfacesToProcess.add(subiface);
                }
            }
        }
    }

    return result;

}

From source file:AndroidUninstallStock.java

public static LinkedList<String> run(String... adb_and_args) throws IOException {
    Process pr = new ProcessBuilder(adb_and_args).redirectErrorStream(true).start();
    BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    LinkedList<String> res = new LinkedList<String>();
    String line;/* ww w . ja  v  a  2s  . c  o  m*/
    while ((line = buf.readLine()) != null) {
        if (!line.isEmpty()) {
            res.add(line);
        }
    }
    try {
        pr.waitFor();
    } catch (InterruptedException e) {
    }
    return res;
}

From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java

private static List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
    LinkedList<ConfigItem> cfg = new LinkedList<>();

    String config = cmd.getConfiguration();
    String disableMonitoring = cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE);

    String args = " -c " + config;
    if (disableMonitoring != null) {
        args = args + " -d";
    }/*  www  .j  a v  a2  s .  c o m*/

    cfg.add(new ScriptConfigItem(VRScripts.MONITOR_SERVICE, args));
    return cfg;
}

From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java

private static List<ConfigItem> generateConfig(SetStaticNatRulesCommand cmd) {
    LinkedList<ConfigItem> cfg = new LinkedList<>();
    if (cmd.getVpcId() != null) {
        for (StaticNatRuleTO rule : cmd.getRules()) {
            String args = rule.revoked() ? " -D" : " -A";
            args += " -l " + rule.getSrcIp();
            args += " -r " + rule.getDstIp();

            cfg.add(new ScriptConfigItem(VRScripts.VPC_STATIC_NAT, args));
        }/* w w w  .  jav  a  2s . c  om*/
    } else {
        for (StaticNatRuleTO rule : cmd.getRules()) {
            //1:1 NAT needs instanceip;publicip;domrip;op
            StringBuilder args = new StringBuilder();
            args.append(rule.revoked() ? " -D " : " -A ");
            args.append(" -l ").append(rule.getSrcIp());
            args.append(" -r ").append(rule.getDstIp());

            if (rule.getProtocol() != null) {
                args.append(" -P ").append(rule.getProtocol().toLowerCase());
            }

            args.append(" -d ").append(rule.getStringSrcPortRange());
            args.append(" -G ");

            cfg.add(new ScriptConfigItem(VRScripts.FIREWALL_NAT, args.toString()));
        }
    }
    return cfg;
}

From source file:com.baidu.rigel.biplatform.tesseract.util.QueryRequestUtil.java

public static SearchIndexResultSet processGroupBy(SearchIndexResultSet dataSet, QueryRequest query,
        QueryContext queryContext) throws NoSuchFieldException {

    List<SearchIndexResultRecord> transList = null;
    long current = System.currentTimeMillis();
    Map<String, Map<String, Set<String>>> leafValueMap = QueryRequestUtil.transQueryRequest2LeafMap(query);
    Map<String, String> allDimVal = collectAllMem(queryContext);

    LOGGER.info("cost :" + (System.currentTimeMillis() - current) + " to collect leaf map.");
    current = System.currentTimeMillis();
    List<String> groupList = Lists.newArrayList(query.getGroupBy().getGroups());
    List<QueryMeasure> queryMeasures = query.getSelect().getQueryMeasures();
    // count?sum//from  www  .  ja v a2s . com
    queryMeasures.forEach(measure -> {
        if (measure.getAggregator().equals(Aggregator.COUNT)) {
            measure.setAggregator(Aggregator.SUM);
        }
    });
    Meta meta = dataSet.getMeta();
    int dimSize = query.getSelect().getQueryProperties().size();
    if (dataSet != null && dataSet.size() != 0 && dataSet instanceof SearchIndexResultSet) {
        transList = dataSet.getDataList();

        if (MapUtils.isNotEmpty(leafValueMap)) {
            // ???
            List<SearchIndexResultRecord> copyLeafRecords = new ArrayList<SearchIndexResultRecord>();
            transList.forEach(record -> {
                leafValueMap.forEach((prop, valueMap) -> {
                    try {
                        String currValue = record.getField(meta.getFieldIndex(prop)) != null
                                ? record.getField(meta.getFieldIndex(prop)).toString()
                                : null;
                        Set<String> valueSet = leafValueMap.get(prop).get(currValue);
                        if (valueSet != null) {
                            int i = 0;
                            for (String value : valueSet) {
                                if (i > 0) {
                                    // ?
                                    SearchIndexResultRecord newRec = DeepcopyUtils.deepCopy(record);
                                    newRec.setField(meta.getFieldIndex(prop), value);
                                    generateGroupBy(newRec, groupList, meta);
                                    copyLeafRecords.add(newRec);
                                } else {
                                    record.setField(meta.getFieldIndex(prop), value);
                                    generateGroupBy(record, groupList, meta);
                                }
                                i++;
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    }
                });
            });
            if (CollectionUtils.isNotEmpty(copyLeafRecords)) {
                // ??
                transList.addAll(copyLeafRecords);
            }
            transList = AggregateCompute.aggregate(transList, dimSize, queryMeasures);
        }
    } else {
        return dataSet;
    }
    LOGGER.info("cost :" + (System.currentTimeMillis() - current) + " to map leaf.");
    current = System.currentTimeMillis();

    if (CollectionUtils.isEmpty(queryMeasures)) {

        dataSet.setDataList(AggregateCompute.distinct(transList));
        return dataSet;
    }

    if (MapUtils.isNotEmpty(allDimVal)) {
        //            List<ResultRecord> preResultList = DeepcopyUtils.deepCopy(transList);
        for (String properties : allDimVal.keySet()) {
            LinkedList<SearchIndexResultRecord> summaryCalcList = new LinkedList<SearchIndexResultRecord>();
            for (SearchIndexResultRecord record : transList) {
                SearchIndexResultRecord vRecord = DeepcopyUtils.deepCopy(record);
                vRecord.setField(meta.getFieldIndex(properties), allDimVal.get(properties));
                //                    generateGroupBy(vRecord, groupList);
                vRecord.setGroupBy(allDimVal.get(properties));
                summaryCalcList.add(vRecord);
            }
            transList.addAll(AggregateCompute.aggregate(summaryCalcList, dimSize, queryMeasures));
        }
    }
    dataSet.setDataList(transList);
    LOGGER.info("cost :" + (System.currentTimeMillis() - current) + " aggregator leaf.");
    return dataSet;
}

From source file:com.cloud.agent.resource.virtualnetwork.ConfigHelper.java

private static List<ConfigItem> generateConfig(SetStaticRouteCommand cmd) {
    LinkedList<ConfigItem> cfg = new LinkedList<>();

    String[][] rules = cmd.generateSRouteRules();
    StringBuilder sb = new StringBuilder();
    String[] srRules = rules[0];/* ww w .jav  a  2  s .c  o m*/

    for (int i = 0; i < srRules.length; i++) {
        sb.append(srRules[i]).append(',');
    }

    String args = " -a " + sb.toString();

    cfg.add(new ScriptConfigItem(VRScripts.VPC_STATIC_ROUTE, args));
    return cfg;
}

From source file:eu.stratosphere.pact.test.contracts.MatchITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {

    LinkedList<Configuration> tConfigs = new LinkedList<Configuration>();

    String[] localStrategies = { PactCompiler.HINT_LOCAL_STRATEGY_SORT_BOTH_MERGE,
            PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_FIRST,
            PactCompiler.HINT_LOCAL_STRATEGY_HASH_BUILD_SECOND };

    String[] shipStrategies = { PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_HASH, "BROADCAST_FIRST",
            "BROADCAST_SECOND" };

    for (String localStrategy : localStrategies) {
        for (String shipStrategy : shipStrategies) {

            Configuration config = new Configuration();
            config.setString("MatchTest#LocalStrategy", localStrategy);
            config.setString("MatchTest#ShipStrategy", shipStrategy);
            config.setInteger("MatchTest#NoSubtasks", 4);

            tConfigs.add(config);
        }/*w  w w .jav  a 2 s  .  com*/
    }

    return toParameterList(MatchITCase.class, tConfigs);
}

From source file:com.erudika.para.rest.RestUtils.java

/**
 * Batch create response as JSON/* ww  w  .j  av  a2 s .c  o m*/
 * @param app the current App object
 * @param is entity input stream
 * @return a status code 200 or 400
 */
public static Response getBatchCreateResponse(final App app, InputStream is) {
    final LinkedList<ParaObject> objects = new LinkedList<ParaObject>();
    Response entityRes = getEntity(is, List.class);
    if (entityRes.getStatusInfo() == Response.Status.OK) {
        List<Map<String, Object>> items = (List<Map<String, Object>>) entityRes.getEntity();
        for (Map<String, Object> object : items) {
            ParaObject pobj = ParaObjectUtils.setAnnotatedFields(object);
            if (pobj != null && ValidationUtils.isValidObject(pobj)) {
                pobj.setAppid(app.getAppIdentifier());
                objects.add(pobj);
            }
        }

        Para.getDAO().createAll(app.getAppIdentifier(), objects);

        Para.asyncExecute(new Runnable() {
            public void run() {
                int typesCount = app.getDatatypes().size();
                app.addDatatypes(objects.toArray(new ParaObject[objects.size()]));
                if (typesCount < app.getDatatypes().size()) {
                    app.update();
                }
            }
        });
    } else {
        return entityRes;
    }
    return Response.ok(objects).build();
}