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:com.adobe.plugins.FastCanvas.java

public static boolean copyMessageQueue(LinkedList<FastCanvasMessage> targetQueue) {
    if (theCanvas == null || theCanvas.mMessageQueue == null) {
        return false;
    }//from w w  w  .  ja v  a 2s . com

    FastCanvasMessage m;
    while ((m = theCanvas.mMessageQueue.poll()) != null) {
        targetQueue.add(m);
    }

    return true;
}

From source file:com.erudika.para.core.CoreUtils.java

/**
 * Returns all objects linked to the given one. Only applicable to many-to-many relationships.
 * @param <P> type of linked objects
 * @param type2 type of linked objects to search for
 * @param obj the object to execute this method on
 * @param pager a {@link com.erudika.para.utils.Pager}
 * @return a list of linked objects/*from w  ww. j  a v a 2 s  . c o m*/
 */
@SuppressWarnings("unchecked")
public static <P extends ParaObject> List<P> getLinkedObjects(ParaObject obj, String type2, Pager... pager) {
    List<Linker> links = getLinks(obj, type2, pager);
    LinkedList<String> keys = new LinkedList<String>();
    for (Linker link : links) {
        if (link.isFirst(type2)) {
            keys.add(link.getId1());
        } else {
            keys.add(link.getId2());
        }
    }
    return new ArrayList<P>(
            (Collection<? extends P>) obj.getDao().readAll(obj.getAppid(), keys, true).values());
}

From source file:Main.java

public static String[] intersect(String[] arr1, String[] arr2) {
    Map<String, Boolean> map = new HashMap<>();
    LinkedList<String> list = new LinkedList<>();
    for (String str : arr1) {
        if (!map.containsKey(str)) {
            map.put(str, Boolean.FALSE);
        }//from   ww  w .j av a2  s .co m
    }

    for (String str : arr2) {
        if (map.containsKey(str)) {
            map.put(str, Boolean.TRUE);
        }
    }

    for (Map.Entry<String, Boolean> e : map.entrySet()) {
        if (e.getValue().equals(Boolean.TRUE)) {
            list.add(e.getKey());
        }
    }
    String[] result = {};
    return list.toArray(result);
}

From source file:com.rathravane.drumlin.util.JsonBodyReader.java

private static List<JSONObject> readArrayForObjects(JSONArray a) throws JSONException {
    final LinkedList<JSONObject> result = new LinkedList<JSONObject>();
    final int len = a.length();
    for (int i = 0; i < len; i++) {
        final Object o = a.get(i);
        if (o instanceof JSONObject) {
            result.add((JSONObject) o);
        } else {/*from ww  w . j  a  v a 2s  .c o  m*/
            throw new JSONException("Expected an object or an array of objects.");
        }
    }
    return result;
}

From source file:eu.stratosphere.pact.test.pactPrograms.KMeansIterationITCase.java

@Parameters
public static Collection<Object[]> getConfigurations() {

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

    Configuration config = new Configuration();
    config.setInteger("KMeansIterationTest#NoSubtasks", 4);
    tConfigs.add(config);

    return toParameterList(tConfigs);
}

From source file:Main.java

public static String[] intersect(String[] arr1, String[] arr2) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    LinkedList<String> list = new LinkedList<String>();
    for (String str : arr1) {
        if (!map.containsKey(str)) {
            map.put(str, Boolean.FALSE);
        }//from w  ww .  j av  a 2 s. c o m
    }

    for (String str : arr2) {
        if (map.containsKey(str)) {
            map.put(str, Boolean.TRUE);
        }
    }

    for (Map.Entry<String, Boolean> e : map.entrySet()) {
        if (e.getValue().equals(Boolean.TRUE)) {
            list.add(e.getKey());
        }
    }

    String[] result = {};
    return list.toArray(result);
}

From source file:cc.recommenders.names.CoReNames.java

public static List<String> src2vmType(final String[] srcTypes) {
    ensureIsNotNull(srcTypes, "srcTypes");
    ///*from  www.jav  a2s  .  c o  m*/
    final LinkedList<String> res = new LinkedList<String>();
    for (final String srcName : srcTypes) {
        res.add(src2vmType(srcName));
    }
    return res;
}

From source file:com.redhat.rhn.frontend.action.systems.monitoring.BaseProbeCreateAction.java

private static List listCommands(CommandGroup group) {
    assert group != null;
    LinkedList commands = new LinkedList();
    Iterator i = MonitoringManager.getInstance().listCommands(group).iterator();
    while (i.hasNext()) {
        Command c = (Command) i.next();// ww  w.j a va 2  s . c  o m
        if (c.isEnabled()) {
            commands.add(c);
        }
    }
    Collections.sort(commands, new CommandComparator());
    return commands;
}

From source file:Main.java

public static LinkedList<String> uc_unserialize(String input) {

    LinkedList<String> result = new LinkedList<String>();

    DOMParser parser = new DOMParser();
    try {/* w ww  .j  av a 2 s. c  om*/
        parser.parse(new InputSource(new StringReader(input)));
        Document doc = parser.getDocument();
        NodeList nl = doc.getChildNodes().item(0).getChildNodes();
        int length = nl.getLength();
        for (int i = 0; i < length; i++) {
            if (nl.item(i).getNodeType() == Document.ELEMENT_NODE)
                result.add(nl.item(i).getNodeValue());
        }
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:Main.java

public static LinkedList<String> uc_unserialize(String input) {

    LinkedList<String> result = new LinkedList<String>();

    DOMParser parser = new DOMParser();
    try {//from  w  w  w  .java  2  s .c o  m
        parser.parse(new InputSource(new StringReader(input)));
        Document doc = parser.getDocument();
        NodeList nl = doc.getChildNodes().item(0).getChildNodes();
        int length = nl.getLength();
        for (int i = 0; i < length; i++) {
            if (nl.item(i).getNodeType() == Document.ELEMENT_NODE)
                result.add(nl.item(i).getTextContent());
        }
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}