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

public static <T> List<T> newOneElementLinkedList(T t) {
    final List<T> result = new LinkedList<T>();
    result.add(t);/*from w w  w.  ja  v  a 2s .c o  m*/
    return result;
}

From source file:Main.java

public static <T> List<T> inReverseOrder(Collection<T> src) {
    LinkedList<T> result = new LinkedList<T>();
    for (T element : src)
        result.addFirst(element);//from   w w  w  . java 2  s  .co m
    return result;
}

From source file:Main.java

public static final List<String> getListFromBundle(ResourceBundle rb, String prefix) {
    String name = null;/*  ww w .  ja v a2 s  .c  o m*/
    List<String> ret = new LinkedList<String>();
    Enumeration<String> names = rb.getKeys();
    while (names.hasMoreElements()) {
        name = names.nextElement();
        if (name != null && name.startsWith(prefix) && isInteger(name.substring(name.length() - 1))) {
            ret.add(rb.getString(name));
        }
    }
    Collections.sort(ret);
    return ret;
}

From source file:Main.java

public static <E> Collection<E> addGreater(Collection<E> collection, E element, Comparator<E> comp) {
    Collection<E> resultColl = new LinkedList<>();
    for (E e : collection) {
        if (comp.compare(e, element) > 0)
            resultColl.add(e);/*from w  w w  .j a va  2 s. c  om*/
    }
    return resultColl;
}

From source file:Main.java

public static <E> List<E> flatten(Collection<? extends Collection<E>> nested) {
    List<E> flat = new LinkedList<>();
    for (Collection<E> current : nested) {
        flat.addAll(current);//from   w  w w.ja  v  a  2 s.  c om
    }
    return flat;
}

From source file:Main.java

public static <K, V> List<V> extractValuesInOrder(Map<K, V> map, List<K> keysList) {
    List<V> vals = new LinkedList<V>();
    for (K key : keysList) {
        vals.add(map.get(key));//from   w  w w.  jav a2 s  . c  om
    }
    return vals;
}

From source file:Main.java

public static LinkedList<String> getAniosVigencia() {
    Calendar c = Calendar.getInstance();
    int anio = c.get(Calendar.YEAR);

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

    int amount = anio + 7;

    for (int i = anio; i < amount; i++) {
        anios.add("" + i);
    }//from  w  w  w.  j av  a2  s  . c  om

    return anios;
}

From source file:Main.java

public static LinkedList<File> listLinkedFiles(String strPath) {
    LinkedList<File> list = new LinkedList<File>();
    File dir = new File(strPath);
    if (!dir.isDirectory()) {
        return null;
    }/* w w  w  . j a  va  2s. c  om*/
    File file[] = dir.listFiles();
    for (int i = 0; i < file.length; i++) {
        if (file[i].isDirectory())
            list.add(file[i]);
        else
            System.out.println(file[i].getAbsolutePath());
    }
    File tmp;
    while (!list.isEmpty()) {
        tmp = (File) list.removeFirst();
        if (tmp.isDirectory()) {
            file = tmp.listFiles();
            if (file == null)
                continue;
            for (int i = 0; i < file.length; i++) {
                if (file[i].isDirectory())
                    list.add(file[i]);
                else
                    System.out.println(file[i].getAbsolutePath());
            }
        } else {
            System.out.println(tmp.getAbsolutePath());
        }
    }
    return list;
}

From source file:Main.java

public static LinkedList<String> loadList(SharedPreferences prefs, String listName) {
    int size = prefs.getInt(listName + "_size", 0);
    LinkedList<String> list = new LinkedList<String>();
    for (int i = 0; i < size; i++) {
        list.add(prefs.getString(listName + "_" + i, null));
    }/*from  ww  w  .j  a  v a2 s. c o m*/
    return list;
}

From source file:Main.java

public static List<String> getAniosConsulta() {
    Calendar c = Calendar.getInstance();
    int anio = c.get(Calendar.YEAR);

    List<String> anios = new LinkedList<String>();
    int amount = anio + 6;

    for (int i = anio; i < amount; i++) {
        anios.add("" + anio--);
    }//from   ww w .ja  v a 2  s  .co  m

    return anios;
}