Example usage for java.util LinkedList size

List of usage examples for java.util LinkedList size

Introduction

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

Prototype

int size

To view the source code for java.util LinkedList size.

Click Source Link

Usage

From source file:AndroidUninstallStock.java

public static LinkedHashMap<String, String> getLibFromPackage(String adb, LinkedList<String> liblist,
        LinkedHashMap<String, String> apklist) throws IOException {
    LinkedHashMap<String, String> libinclude = new LinkedHashMap<String, String>();
    File libget = File.createTempFile("AndroidUninstallStockLibs", null);
    for (Map.Entry<String, String> info : sortByValues(apklist).entrySet()) {
        System.out.print("* Libs in " + info.getKey() + " (" + info.getValue() + ")");
        LinkedList<String> pull = run(adb, "-s", lastdevice, "pull", "\"" + info.getKey() + "\"",
                "\"" + libget.getCanonicalPath() + "\"");
        if (pull.size() > 0 && pull.get(0).indexOf("does not exist") > 0) {
            System.out.println(" - file not exist");
            continue;
        }//w  w w . j  a v a  2  s .  c o m
        LinkedList<String> libinapk = getLibsInApk(libget.toPath());
        if (libinapk.size() == 0) {
            System.out.println(" - empty");
        } else {
            System.out.println(":");
            for (String libpath : libinapk) {
                String libname = libpath.substring(libpath.lastIndexOf('/') + 1);
                boolean libfound = false;
                for (String lb : liblist) {
                    if (lb.indexOf(libname) > -1) {
                        System.out.println(libpath + " = " + lb);
                        libinclude.put(lb,
                                (libinclude.containsKey(libname) ? libinclude.get(libname) + ", " : "")
                                        + info.getKey());
                        libfound = true;
                    }
                }
                if (!libfound) {
                    System.out.println(libpath + " = not found");
                }
            }
        }
    }
    try {
        libget.delete();
    } catch (Exception e) {
    }
    return libinclude;
}

From source file:at.bitfire.davdroid.resource.LocalCalendar.java

public static LocalCalendar[] findAll(Account account, ContentProviderClient providerClient)
        throws RemoteException {
    @Cleanup//from  www .j av a  2s . co  m
    Cursor cursor = providerClient.query(calendarsURI(account), new String[] { Calendars._ID, Calendars.NAME },
            Calendars.DELETED + "=0 AND " + Calendars.SYNC_EVENTS + "=1", null, null);

    LinkedList<LocalCalendar> calendars = new LinkedList<>();
    while (cursor != null && cursor.moveToNext())
        calendars.add(new LocalCalendar(account, providerClient, cursor.getInt(0), cursor.getString(1)));
    return calendars.toArray(new LocalCalendar[calendars.size()]);
}

From source file:de.vanita5.twittnuker.util.net.ssl.AbstractCheckSignatureVerifier.java

/**
 * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate.
 * Returns null if there aren't any.//from  w  ww. j  a v a  2 s  .  c om
 *
 * @param cert X509Certificate
 * @param hostname
 * @return Array of SubjectALT DNS or IP names stored in the certificate.
 */
private static String[] getSubjectAlts(final X509Certificate cert, final String hostname) {
    final int subjectType;
    if (isIPAddress(hostname)) {
        subjectType = 7;
    } else {
        subjectType = 2;
    }

    final LinkedList<String> subjectAltList = new LinkedList<String>();
    Collection<List<?>> c = null;
    try {
        c = cert.getSubjectAlternativeNames();
    } catch (final CertificateParsingException cpe) {
    }
    if (c != null) {
        for (final List<?> aC : c) {
            final List<?> list = aC;
            final int type = ((Integer) list.get(0)).intValue();
            if (type == subjectType) {
                final String s = (String) list.get(1);
                subjectAltList.add(s);
            }
        }
    }
    if (!subjectAltList.isEmpty()) {
        final String[] subjectAlts = new String[subjectAltList.size()];
        subjectAltList.toArray(subjectAlts);
        return subjectAlts;
    } else
        return null;
}

From source file:eulermind.importer.LineNode.java

private static LineNode reduceToChapterTreeByBlankLine(List<LineNode> lineNodes) {
    LinkedList<LineNode> newlineNodes = new LinkedList<LineNode>();

    //??, /* w  w w .ja va  2  s  .  c o m*/
    for (LineNode lineNode : lineNodes) {
        if (lineNode.m_blankLines > 200) {
            lineNode.m_blankLines = 200;
        }
    }
    Iterator<LineNode> iterator = lineNodes.iterator();
    newlineNodes.add(iterator.next());

    //lineNode ?????newLineNodes
    //

    //?????
    {
        int maxBlankLines = 0;
        while (iterator.hasNext()) {
            LineNode lineNode = iterator.next();
            maxBlankLines = Math.max(maxBlankLines, lineNode.m_blankLines);

            //
            for (int i = newlineNodes.peekLast().m_blankLines + 1; i < lineNode.m_blankLines; i++) {
                newlineNodes.add(new LineNode(i));
            }
            newlineNodes.add(lineNode);
        }

        //
        for (int i = newlineNodes.peekLast().m_blankLines + 1; i <= maxBlankLines + 1; i++) {
            newlineNodes.add(new LineNode(i));
        }
    }

    //?
    LinkedList<LineNode> stack = new LinkedList<LineNode>();

    for (LineNode newLineNode : newlineNodes) {
        if (!stack.isEmpty() && stack.peekLast().m_blankLines < newLineNode.m_blankLines) {
            List<LineNode> reducedLineNodes = popSameBlankLineNodes(stack);

            for (LineNode reducedLineNode : reducedLineNodes) {
                newLineNode.add(reducedLineNode);
            }
        }

        stack.add(newLineNode);
    }

    assert stack.size() == 1;

    return stack.peekFirst();
}

From source file:com.epam.reportportal.apache.http.conn.ssl.AbstractVerifier.java

/**
 * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate.
 * Returns null if there aren't any.//from w w w  .  ja v  a2s.  co  m
 *
 * @param cert X509Certificate
 * @param hostname
 * @return Array of SubjectALT DNS or IP names stored in the certificate.
 */
private static String[] getSubjectAlts(final X509Certificate cert, final String hostname) {
    final int subjectType;
    if (isIPAddress(hostname)) {
        subjectType = 7;
    } else {
        subjectType = 2;
    }

    final LinkedList<String> subjectAltList = new LinkedList<String>();
    Collection<List<?>> c = null;
    try {
        c = cert.getSubjectAlternativeNames();
    } catch (final CertificateParsingException cpe) {
    }
    if (c != null) {
        for (final List<?> aC : c) {
            final List<?> list = aC;
            final int type = ((Integer) list.get(0)).intValue();
            if (type == subjectType) {
                final String s = (String) list.get(1);
                subjectAltList.add(s);
            }
        }
    }
    if (!subjectAltList.isEmpty()) {
        final String[] subjectAlts = new String[subjectAltList.size()];
        subjectAltList.toArray(subjectAlts);
        return subjectAlts;
    } else {
        return null;
    }
}

From source file:soap.ui.stats.OverLaidBarChartFactory.java

public static JFreeChart createDualBarAndLineDiagram(String title, String categoryAxisLabel,
        String valueAxisLabel, CategoryDataset barDiagramDataset, LinkedList lineDiagramDatasets) {
    CategoryPlot plot = new CategoryPlot();
    int inc = 0;//from   ww  w.j  av  a2 s . c om
    BarRenderer barRenderer = null;
    if (barDiagramDataset != null) {
        plot.setDataset(barDiagramDataset);
        barRenderer = new BarRenderer3D();
        barRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        plot.setRenderer(barRenderer);
        inc = 1;
        plot.setDomainAxis(new CategoryAxis3D(categoryAxisLabel));
        plot.setRangeAxis(new NumberAxis3D(valueAxisLabel));
    } else {
        plot.setDomainAxis(new CategoryAxis(categoryAxisLabel));
        plot.setRangeAxis(new NumberAxis(valueAxisLabel));
    }
    plot.mapDatasetToRangeAxis(0, 0);

    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    CategoryItemRenderer renderers[] = new LineAndShapeRenderer[lineDiagramDatasets.size()];

    for (int i = 0; i < lineDiagramDatasets.size(); i++) {
        CategoryDataset lineDiagramDataset = (CategoryDataset) lineDiagramDatasets.get(i);
        plot.setDataset(i + inc, lineDiagramDataset);
        plot.mapDatasetToRangeAxis(i + inc, 0);
        if (barDiagramDataset != null && i < barDiagramDataset.getRowCount()) {
            renderers[i] = new LineAndShapeRendererMapToBar(barRenderer, i);
        } else {
            renderers[i] = new LineAndShapeRenderer();
        }
        renderers[i].setToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderers[i].setSeriesStroke(0, new BasicStroke(1.5f));
        renderers[i].setSeriesStroke(1, new BasicStroke(1.5f));
        plot.setRenderer(i + inc, renderers[i]);
    }

    CategoryDataset dataset;
    if (lineDiagramDatasets.size() > 0)
        dataset = (CategoryDataset) lineDiagramDatasets.get(0);
    else
        dataset = barDiagramDataset;
    for (int i = 0; i < dataset.getColumnCount(); i++)
        plot.getDomainAxis().addCategoryLabelToolTip(dataset.getColumnKey(i), (String) dataset.getColumnKey(i));

    plot.setRangeGridlinePaint(Color.black);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(title);
    chart.setLegend(new StandardLegend());

    return chart;
}

From source file:dk.netarkivet.common.utils.ProcessUtils.java

/**
 * Runs a system process (Unix sort) to sort a file.
 * @param inputFile the input file.//w ww  .j a  v a2s . c om
 * @param outputFile the output file.
 * @param tempDir the directory where to store temporary files (null for default system temp).
 * @param crawllogSorting Should we sort crawllog style ("-k 4b") or not
 * @return the process exit code.
 */
public static int runUnixSort(File inputFile, File outputFile, File tempDir, boolean crawllogSorting) {
    String[] environment = new String[] { "LANG=C" };
    LinkedList<String> cmdAndParams = new LinkedList<String>();
    cmdAndParams.add("sort");
    cmdAndParams.add(inputFile.getAbsolutePath());
    if (crawllogSorting) {
        // -k 4b means fourth field (from 1) ignoring leading blanks
        cmdAndParams.add("-k");
        cmdAndParams.add("4b");
    }
    // -o means output to (file)
    cmdAndParams.add("-o");
    cmdAndParams.add(outputFile.getAbsolutePath());

    if (tempDir != null) {
        // -T configures where to store temporary files
        cmdAndParams.add("-T");
        cmdAndParams.add(tempDir.getAbsolutePath());
    }

    return ProcessUtils.runProcess(environment,
            (String[]) cmdAndParams.toArray(new String[cmdAndParams.size()]));
}

From source file:data_gen.Data_gen.java

private static void multi_enum_json(HashMap<String, Object> fields, String key, String value) {
    try {//from  w w  w.j  av  a 2s . c o m
        String[] values = value.split(":");
        String trim_val = values[1].substring(1, values[1].length() - 1);
        String[] possible_values = trim_val.split(",");
        LinkedList<String> all = new LinkedList(Arrays.asList(possible_values));
        Random rand = new Random();
        Random rand2 = new Random();
        String result = "";
        int r = rand.nextInt(possible_values.length - 1);
        if (r == 0) {
            r = 1;
        }
        String[] words = new String[r];
        for (int i = 0; i < r; i++) {
            int r2 = rand.nextInt(all.size() - 1);
            words[i] = all.get(r2);
            all.remove(r2);
        }
        List<String> myList = new ArrayList<>(Arrays.asList(words));

        fields.put(key, myList);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("Make sure you have the right multi value enumeration format in configration file");
        System.out.println("example:    multi:[science,sport,art,literature,politics]" + "\n");
        System.exit(0);

    }

}

From source file:data_gen.Data_gen.java

private static void multi_enum_dat(HashMap<String, Object> fields, String key, String value) {
    try {/*from   w  ww .ja va  2  s .  c  o m*/
        String[] values = value.split(":");
        String trim_val = values[1].substring(1, values[1].length() - 1);
        String[] possible_values = trim_val.split(",");
        LinkedList<String> all = new LinkedList(Arrays.asList(possible_values));
        Random rand = new Random();
        Random rand2 = new Random();
        String result = "";
        int r = rand.nextInt(possible_values.length - 1);
        if (r == 0) {
            r = 1;
        }
        String[] words = new String[r];
        for (int i = 0; i < r; i++) {
            int r2 = rand.nextInt(all.size() - 1);
            words[i] = all.get(r2);
            all.remove(r2);
        }
        String multi_values = "";
        for (int i = 0; i < words.length; i++) {
            multi_values += words[i] + (char) 59;
        }
        multi_values = multi_values.substring(0, multi_values.length() - 1);
        fields.put(key, multi_values);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("Make sure you have the right multi value enumeration format in configration file");
        System.out.println("example:    multi:[science,sport,art,literature,politics]" + "\n");
        System.exit(0);

    }

}

From source file:io.hops.common.INodeUtil.java

public static boolean resolvePathWithNoTransaction(String path, boolean resolveLink,
        LinkedList<INode> preTxResolvedINodes)
        throws UnresolvedPathException, StorageException, TransactionContextException {
    preTxResolvedINodes.clear();//from  w w w  .j a v a  2  s  .  c om

    byte[][] components = INode.getPathComponents(path);
    INode curNode = getRoot();
    preTxResolvedINodes.add(curNode);

    if (components.length == 1) {
        return false;
    }

    INodeResolver resolver = new INodeResolver(components, curNode, resolveLink, false);
    while (resolver.hasNext()) {
        curNode = resolver.next();
        if (curNode != null) {
            preTxResolvedINodes.add(curNode);
        }
    }
    return preTxResolvedINodes.size() == components.length;
}