Example usage for java.util ArrayList ArrayList

List of usage examples for java.util ArrayList ArrayList

Introduction

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

Prototype

public ArrayList() 

Source Link

Document

Constructs an empty list with an initial capacity of ten.

Usage

From source file:org.mili.jmibs.jfree.examples.Example5.java

/**
 * @param args//www . j  a  v a 2s. c  om
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new ReplaceStringBenchmark());
    bs.addBenchmark(new ReplaceStringAppendBenchmark());
    bs.addBenchmark(new ReplaceStringAppendSingleBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example4.java

/**
 * @param args/*from w w  w . j  a  v a 2s. c o  m*/
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new AppendStringBufferBenchmark());
    bs.addBenchmark(new AppendStringBuilderBenchmark());
    bs.addBenchmark(new AppendStringConcatBenchmark());
    bs.addBenchmark(new AppendStringPlusBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example3.java

/**
 * @param args//from   ww  w .ja v  a2s. c om
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new TraverseForEachArrayListStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomArrayListStringBenchmark());
    bs.addBenchmark(new TraverseForEachVectorStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomVectorStringVariableOutsideBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomVectorStringBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example6.java

/**
 * @param args/*from   ww w. jav a2 s . c  o  m*/
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(10);
            add(20);
            add(30);
            add(40);
            add(50);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    // really slow ...
    //bs.addBenchmarkClass(FibonacciRecursiveBenchmark.class);
    bs.addBenchmark(new FibonacciEndRecursiveBenchmark());
    bs.addBenchmark(new FibonacciNonRecursiveBenchmark());
    bs.addBenchmark(new FibonacciExplicitBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:example.Example.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.err.println("Usage: Example username:password ... [-f twitter_id ...] [-t keyword]");
        System.exit(1);/*from  www . java  2s  .c  o  m*/
    }

    Collection<String> credentials = new ArrayList<String>();
    Collection<String> followIds = null;
    Collection<String> trackKeywords = null;

    Collection<String> list = credentials;

    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("-f")) {
            followIds = new ArrayList<String>();
            list = followIds;
        } else if (arg.equals("-t")) {
            trackKeywords = new ArrayList<String>();
            list = trackKeywords;
        } else {
            list.add(arg);
        }
    }

    final Collection<String> finalFollowIds = followIds;
    final Collection<String> finalTrackKeywords = trackKeywords;

    FilterParameterFetcher filterParameterFetcher = new FilterParameterFetcher() {
        public Collection<String> getFollowIds() {
            return finalFollowIds;
        }

        public Collection<String> getTrackKeywords() {
            return finalTrackKeywords;
        }
    };

    new TwitterClient(filterParameterFetcher, new ExampleTwitterStreamProcessor(),
            "http://stream.twitter.com/1/statuses/filter.json", 200, 10, credentials, 60 * 1000L).execute();
}

From source file:Employee.java

public static void main(String[] args) {
    String[] names = { "A", "B", "C", "D" };

    double[] salaries = { 2.0, 5.0, 6.0, 4.0 };

    List l = new ArrayList();

    for (int i = 0; i < names.length; i++)
        l.add(new Employee(names[i], salaries[i]));

    Collections.sort(l);//w w w.  j  av a 2s  .  c  o  m

    ListIterator liter = l.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());

    Collections.sort(l, new Employee.SalaryComparator());

    liter = l.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());
}

From source file:com.croer.javaaccess.ItemBusqTest.java

public static void main(String[] args) {
    FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
            "C:\\Users\\IBM_ADMIN\\Documents\\@Projects_Eli\\201309 Finder&Getter\\_NBP\\digitalcatalog\\JavaAccess\\src\\main\\java\\springXMLConfig.xml");
    ItembusqManagement bean3 = context.getBean("itembusqManagement", ItembusqManagement.class);
    OrtogramaRepository ortoRepo = context.getBean("ortogramaRepository", OrtogramaRepository.class);
    ItembusqRepository itemRepo = context.getBean("itembusqRepository", ItembusqRepository.class);

    Ortograma ortoTmp = ortoRepo.findOne("vaca");
    List<Ortograma> ortoList = new ArrayList<>();
    ortoList.add(ortoTmp);/*  ww  w .ja  va 2  s.c o m*/
    Itembusq itembusq = itemRepo.findOne(new ItembusqPK("Producto", "99"));
    bean3.borraOrtograma(ortoList, itembusq);
}

From source file:com.mirth.connect.model.converters.tests.NCPDPTest.java

public static void main(String[] args) throws Exception {
    String testMessage = "";
    ArrayList<String> testFiles = new ArrayList<String>();
    testFiles.add("C:\\NCPDP_51_B1_Request.txt");
    testFiles.add("C:\\NCPDP_51_B1_Request_v2.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v3.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v4.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v5.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v6.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v7.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v8.txt");
    testFiles.add("C:\\NCPDP_51_B1_Response_v9.txt");
    testFiles.add("C:\\NCPDP_51_B2_Request.txt");
    testFiles.add("C:\\NCPDP_51_B2_Request_v2.txt");
    testFiles.add("C:\\NCPDP_51_B2_Response.txt");
    testFiles.add("C:\\NCPDP_51_B2_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_B2_Response_v3.txt");
    testFiles.add("C:\\NCPDP_51_B3_Request.txt");
    testFiles.add("C:\\NCPDP_51_B3_Response.txt");
    testFiles.add("C:\\NCPDP_51_B3_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_B3_Response_v3.txt");
    testFiles.add("C:\\NCPDP_51_E1_Request.txt");
    testFiles.add("C:\\NCPDP_51_E1_Response.txt");
    testFiles.add("C:\\NCPDP_51_E1_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_E1_Response_v3.txt");
    testFiles.add("C:\\NCPDP_51_E1_Response_v4.txt");
    testFiles.add("C:\\NCPDP_51_E1_Response_v5.txt");
    testFiles.add("C:\\NCPDP_51_N1_Request.txt");
    testFiles.add("C:\\NCPDP_51_N2_Request.txt");
    testFiles.add("C:\\NCPDP_51_P1_Request.txt");
    testFiles.add("C:\\NCPDP_51_P1_Response.txt");
    testFiles.add("C:\\NCPDP_51_P1_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_P1_Response_v3.txt");
    testFiles.add("C:\\NCPDP_51_P2_Request.txt");
    testFiles.add("C:\\NCPDP_51_P2_Response.txt");
    testFiles.add("C:\\NCPDP_51_P3_Request.txt");
    testFiles.add("C:\\NCPDP_51_P3_Response.txt");
    testFiles.add("C:\\NCPDP_51_P3_Response_v2.txt");
    testFiles.add("C:\\NCPDP_51_P4_Request.txt");
    testFiles.add("C:\\NCPDP_51_P4_Response.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_1.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_2.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_3.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_4.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_5.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_6.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_7.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_8.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_9.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_10.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_11.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_12.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_13.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_14.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_15.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_16.txt");
    testFiles.add("C:\\NCPDP_51_CALPOS_17.txt");

    for (String testFile : testFiles) {
        testMessage = new String(FileUtils.readFileToByteArray(new File(testFile)));
        System.out.println("Processing test file:" + testFile);

        try {//  w  w  w.j a v a 2 s. c  o m
            long totalExecutionTime = 0;
            int iterations = 1;
            for (int i = 0; i < iterations; i++) {
                totalExecutionTime += runTest(testMessage);
            }

            //System.out.println("Execution time average: " + totalExecutionTime/iterations + " ms");
        }
        // System.out.println(new X12Serializer().toXML("SEG*1*2**4*5"));
        catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:org.mili.jmibs.jfree.examples.Example2.java

/**
 * @param args//w w  w. j  ava  2s.  c  om
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new TraverseForEachArrayListStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomArrayListStringBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    /*
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?{
     * To create a JFreeChart for an object load suite result, use class
     * &quot;JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer&quot;. It produces
     * a simple chart from your results. The application is as the string renderer. It
     * renders to an JFreeChart object. Simply switch the renderer like following:}
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?(Pre){
     * BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer.create(); }
     */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    /*
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?{
     * This chart you can pack into a chart panel and application frame, like this:}
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?(Pre){
     * ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
     * ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
     * chartPanel.setFillZoomRectangle(true);
     * chartPanel.setMouseZoomable(true);
     * chartPanel.setPreferredSize(new Dimension(640, 480));
     * af.setContentPane(chartPanel);
     * af.pack(); RefineryUtilities.centerFrameOnScreen(af);
     * af.setVisible(true); }
     */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:com.apextom.util.CollectionUtil.java

public static void main(String[] args) {
    List<Object> list = new ArrayList<Object>();
    list.add("aa");
    list.add(null);/*from   w ww .  j a v a2  s.c  o m*/
    list.add(null);
    System.out.println(list);
    removeNull(list);
    System.out.println(list);

}