Example usage for java.util LinkedList LinkedList

List of usage examples for java.util LinkedList LinkedList

Introduction

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

Prototype

public LinkedList() 

Source Link

Document

Constructs an empty list.

Usage

From source file:Main.java

/**
 * Get all direct child elements with a given name, for a parent element.
 * @param e/*from  ww  w .j a v a 2  s .c  o  m*/
 * @return
 */
public static List<Element> getChildElements(Element e, String name) {
    if (e == null)
        return null;
    List<Element> result = new LinkedList<Element>();
    NodeList list = e.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node n = list.item(i);
        if (n instanceof Element) {
            if (name == null || name.equals(n.getLocalName()) || n.getLocalName().endsWith(":" + name)) {
                result.add((Element) n);
            }
        }
    }
    return result;
}

From source file:Main.java

/**
 * Get all direct child elements with a given name, for a parent element.
 * @param e//  w ww .  j  av  a 2s.  c o m
 * @return
 */
public static List<Element> getChildElements(Element e, String name) {
    if (e == null)
        return null;
    List<Element> result = new LinkedList<Element>();
    NodeList list = e.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node n = list.item(i);
        if (n instanceof Element) {
            if (name == null || name.equals(((Element) n).getLocalName())
                    || ((Element) n).getLocalName().endsWith(":" + name)) {
                result.add((Element) n);
            }
        }
    }
    return result;
}

From source file:Main.java

public static List<String> getAllLeaves(Element element) {
    // Get a list of strings representing the relative path
    // (including the current element) to all the leaf elements
    // under the current element

    // Eric: Why return a List? Returning a Set seems to make
    // more sense.

    if (element == null) {
        return null;
    }//from w w w . j av  a 2  s .  c o m

    List<String> ret = new LinkedList<String>();
    if (isLeaf(element)) {
        ret.add(element.getNodeName());
    } else {
        NodeList nl = element.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node n = nl.item(i);
            if (n instanceof Element) {
                Element childElement = (Element) n;
                for (String childNodeName : getAllLeaves(childElement)) {
                    ret.add(element.getNodeName() + "/" + childNodeName);
                }
            }
        }
    }

    return ret;
}

From source file:Main.java

public static Collection<Node> getNodesByName(Node node, String name) {
    Collection<Node> list = new LinkedList<Node>();

    NodeList nl = node.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++)
        if (nl.item(i).getNodeName().equals(name))
            list.add(nl.item(i));//from   w  ww  . j  ava  2 s  . c  om

    return list;
}

From source file:com.ro.ssc.app.client.utils.AccessReader.java

public static List<Set<String>> updateUserMap(File file) {

    Set<String> excludedGates = new LinkedHashSet<>();
    Set<String> excludedUsers = new LinkedHashSet<>();
    Set<String> idMapping = new LinkedHashSet<>();
    List<Set<String>> result = new LinkedList<>();

    Table table;/* ww w. jav  a  2  s .  com*/
    try {

        table = DatabaseBuilder.open(file).getTable("t_b_Reader");
        Cursor cursor = CursorBuilder.createCursor(table);
        for (Row row : cursor.newIterable().addMatchPattern("f_Attend", 0)) {

            excludedGates.add(String.format("%s", row.get("f_ReaderName")));
        }
        table = DatabaseBuilder.open(file).getTable("t_b_Consumer");
        cursor = CursorBuilder.createCursor(table);
        for (Row row : cursor.newIterable()) {
            idMapping.add(String.format("%s", row.get("f_ConsumerID")).trim() + "-"
                    + WordUtils.capitalizeFully(String.format("%s", row.get("f_ConsumerName")).trim()));

            if (!String.format("%s", row.get("f_AttendEnabled")).contains("1")) {
                excludedUsers.add(WordUtils.capitalizeFully(String.format("%s", row.get("f_ConsumerName"))));
            }
        }

    } catch (IOException ex) {
        log.error("Exceptie", ex);
    }

    result.add(idMapping);
    result.add(excludedGates);
    result.add(excludedUsers);

    return result;
}

From source file:jp.troter.tags.capture.CaptureUtil.java

public static LinkedList<String> nullToEmptyList(LinkedList<String> list) {
    return (list == null) ? new LinkedList<String>() : list;
}

From source file:Main.java

private static <T> void permutationsImpl(List<Collection<T>> ori, Collection<List<T>> res, int d,
        List<T> current) {/*from  w  w  w.  j  a  va 2  s.  c  om*/
    if (d == ori.size()) {
        res.add(current);
        return;
    }
    // iterate from current collection and copy 'current' element N times, one for each element
    Collection<T> currentCollection = ori.get(d);
    for (T element : currentCollection) {
        List<T> copy = new LinkedList<T>();
        copy.addAll(current);
        copy.add(element);
        permutationsImpl(ori, res, d + 1, copy);
    }
}

From source file:Main.java

public static <T> Collection<T> makeCollection(final Iterator<T> i) {
    final List<T> list = new LinkedList<T>();
    while (i.hasNext()) {
        list.add(i.next());/*from  w ww .  j  a v  a  2 s.co m*/
    }
    return list;
}

From source file:Main.java

/**
 * //  w w w . ja va2  s.c  om
 * <pre>
 * {@code
 * filter(listOfStrings, (String str) -> !str.isEmpty());
 * 
 * IntPredicate evnNumbers = (int i) -> i % 2 == 0; //to avoid autoboxing rather than (Integer i) -> i % 2 == 0;
 * filter(listOfIntegers, evenNumbers);
 * }
 * </pre>
 * 
 * @param list
 * @param predicate
 * @return
 */
public static <T> List<T> filter(List<T> list, Predicate<T> predicate) {
    List<T> filtered = new LinkedList<>();
    for (T entry : list) {
        if (predicate.test(entry)) {
            filtered.add(entry);
        }
    }
    return filtered;
}

From source file:com.hbc.api.trade.order.OrderPal.java

public static List<Integer> getNotSettlementOrderStatus() {
    List<Integer> orderStatusList = new LinkedList<>();
    orderStatusList.add(OrderStatus.PAYSUCCESS.value);
    orderStatusList.add(OrderStatus.GUIDE_ARRIVED.value);
    orderStatusList.add(OrderStatus.PICK_CUSTOMER.value);
    orderStatusList.add(OrderStatus.STROKE_END.value);
    orderStatusList.add(OrderStatus.CANCELING.value);
    orderStatusList.add(OrderStatus.DISPUTING.value);
    orderStatusList.add(OrderStatus.CONFIRMED_COST.value);
    return orderStatusList;
}