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:listduplicatingfiles.ListDuplicatingFiles.java

public void listDuplicatingFiles(Path dir) {
    File myFile = dir.toFile();/* www.  j ava2 s  .  c  o m*/
    List<File> nonDuplicated = new LinkedList<File>();

    for (File fileEntry : myFile.listFiles()) {
        if (fileEntry.isDirectory()) {

            System.out.println(fileEntry.getName());
            listDuplicatingFiles(fileEntry.toPath());

        } else {
            if (!isDuplicated(nonDuplicated, fileEntry)) {
                nonDuplicated.add(fileEntry);
            }
            //System.out.println(fileEntry.getName());
        }
    }

    for (File file : nonDuplicated) {
        System.out.println(file);
    }

}

From source file:com.github.rwhogg.git_vcr.Util.java

/**
 * getFilesChanged returns a list of all the files changed by this patch
 * @param patch The patch to check//from  w  w w.java  2  s .  c o m
 * @return a list of pairs of files changed (first is the old path, second is the new path)
 */
public static List<ImmutablePair<String, String>> getFilesChanged(Patch patch) {
    List<ImmutablePair<String, String>> changeList = new LinkedList<>();
    List<? extends FileHeader> headers = patch.getFiles();
    for (FileHeader header : headers) {
        ImmutablePair<String, String> pair = new ImmutablePair<>(header.getOldPath(), header.getNewPath());
        changeList.add(pair);
    }
    return changeList;
}

From source file:view.visualization.TXTVisualization.java

public static void drawChart(String a, String b, String txt) {
    String[] boje = null;/*from   ww w . j  a v a 2s.c  o m*/
    LinkedList<String> atributi = new LinkedList<String>();
    LinkedList<String> sviAtributi = new LinkedList<String>();
    String[] vrAtribut = null;
    XYSeries[] xy = null;
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    int brojac = 0;
    boolean kraj = false;
    LinkedList<Integer> numeric = new LinkedList<Integer>();

    try {
        BufferedReader in = new BufferedReader(new FileReader(txt));
        int br = Integer.parseInt(in.readLine().split(" ")[1]);
        for (int j = 0; j < br + 1; j++) {

            String pom = in.readLine();
            if (pom.contains("@attribute")) {
                if (pom.contains("numeric")) {
                    sviAtributi.add(pom.substring(11, pom.lastIndexOf("n") - 1));
                } else {
                    sviAtributi.add(pom.split(" ")[1]);
                }
            }
            if (pom.contains("@attribute") && pom.contains("numeric")) {
                atributi.add(pom.substring(11, pom.lastIndexOf("n") - 1));
            }
            if (!pom.contains("numeric")) {
                brojac++;
                numeric.add(j - 2);
            }

        }
        String s = in.readLine();
        boje = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")).split(",");
        xy = new XYSeries[boje.length];
        for (int i = 0; i < boje.length; i++) {

            xy[i] = new XYSeries(boje[i]);

        }
        while (!kraj) {
            String pom2 = in.readLine();

            if (!(pom2.contains("@data"))) {
                vrAtribut = pom2.split(",");
                for (int i = 0; i < xy.length; i++) {
                    if (xy[i].getKey().equals(vrAtribut[vrAtribut.length - 1])) {

                        xy[i].add(Double.parseDouble(vrAtribut[sviAtributi.indexOf(a)]),
                                Double.parseDouble(vrAtribut[sviAtributi.indexOf(b)]));

                    }
                }
            }
        }
        in.close();
    } catch (Exception e) {
        e.getMessage();
    }
    for (int i = 0; i < xy.length; i++) {
        xySeriesCollection.addSeries(xy[i]);
    }

    JFreeChart grafik = ChartFactory.createScatterPlot("Vizuelizacija", a, b, xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    ChartFrame proba = new ChartFrame("DataMiner", grafik);

    proba.setVisible(true);
    proba.setSize(500, 600);

}

From source file:io.github.azige.mages.Util.java

static List<Plugin> loadPluginsFromDirectory(File dir) {
    List<Plugin> list = new LinkedList<>();
    File[] files = dir.listFiles(new FilenameFilter() {

        @Override//from  w  w  w. j av  a2s  .  co  m
        public boolean accept(File dir, String name) {
            return name.endsWith(".groovy");
        }
    });
    if (files == null) {
        return list;
    }
    try {
        GroovyClassLoader loader = new GroovyClassLoader();
        loader.addClasspath(dir.getCanonicalPath());
        final int extLength = ".groovy".length();
        for (File f : files) {
            String name = f.getName();
            String script = FileUtils.readFileToString(f, "UTF-8");
            list.add(wrapPlugin(name.substring(0, name.length() - extLength),
                    loader.parseClass(script).newInstance()));
        }
    } catch (Exception ex) {
        throw new MagesException(ex);
    }
    return list;
}

From source file:com.aliyun.odps.mapred.bridge.TestUtils.java

private static List<String> fileToLines(String path) {
    List<String> lines = new LinkedList<String>();
    String line = "";
    try {// w w w . j av a 2 s.co m
        BufferedReader in = new BufferedReader(new FileReader(path));
        while ((line = in.readLine()) != null) {
            lines.add(line);
        }
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return lines;
}

From source file:com.hunchee.haystack.server.JSONHelper.java

public static Map<String, Object> parseJson(String jsonText) throws ParseException {
    Map<String, Object> json = null;
    org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
    ContainerFactory containerFactory = new ContainerFactory() {
        public List creatArrayContainer() {
            return new LinkedList();
        }//from w  ww.  ja  v  a  2s .  c  o  m

        public Map createObjectContainer() {
            return new LinkedHashMap();
        }
    };
    json = (Map<String, Object>) parser.parse(jsonText, containerFactory);
    Iterator iter = json.entrySet().iterator();
    LOG.info("==iterate result==");
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        LOG.info(entry.getKey() + "=>" + entry.getValue());
    }
    LOG.info("==toJSONString()==");
    LOG.info(org.json.simple.JSONValue.toJSONString(json));
    return json;
}

From source file:de.tor.tribes.util.VillageUtils.java

public static Village[] getVillages(Tribe[] pTribes) {
    List<Village> villageList = new LinkedList<>();
    if (pTribes == null || pTribes.length == 0) {
        Set<Entry<Integer, Village>> entries = DataHolder.getSingleton().getVillagesById().entrySet();
        for (Entry<Integer, Village> entry : entries) {
            villageList.add(entry.getValue());
        }//  w  w  w.j ava  2 s .com
    } else {
        for (Tribe t : pTribes) {
            Collections.addAll(villageList, t.getVillageList());
        }
    }
    return villageList.toArray(new Village[villageList.size()]);
}

From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.Cuerpo.java

public Cuerpo() {

    atributos = new LinkedList<>();
}

From source file:net.decix.jatlasx.ripe.atlas.api.handler.TracesHandler.java

public List<IpAddress> handleResponse(String jsonString) {

    List<IpAddress> traceIPs = new LinkedList<IpAddress>();
    JSONArray jsonArray = new JSONArray(jsonString);

    for (int y = 0; y < jsonArray.length(); y++) {
        JSONObject jsonObject = (JSONObject) jsonArray.get(y);
        JSONArray resultArray = new JSONArray(jsonObject.get("result").toString());

        if (resultArray != null) {
            TraceHandler handler = new TraceHandler();
            traceIPs.addAll(handler.handleResponse(resultArray.toString()));
        }/*w  w  w. j  a  va2s .  co  m*/
    }
    return traceIPs;
}

From source file:bakuposter.gcm.server.Content.java

public void addRegId(String regId) {
    if (registration_ids == null) {
        registration_ids = new LinkedList<String>();
    }// ww w.ja  va2 s. c  o m
    registration_ids.add(regId);
}