Package java.util

Examples of java.util.ArrayList.subList()


            boolean del = r.nextBoolean();
            int pos = r.nextInt(result.size() + 1);
            int len = Math.min(result.size() - pos, 1 + r.nextInt(4));
            if (del && result.size() > 0)
            { // delete
                result.subList(pos, pos + len).clear();
            }
            else
            {
                for (int k = 0; k < len; k++, pos++)
                {
View Full Code Here


           
           
            if (!forward) {
                // If the retrieved lines includes line numbers beyond the search start line, we must remove them to prevent them from being searched (can only happen in backward mode)
                if (offset + lines.size() > searchStartLine) {
                    lines = lines.subList(0, searchStartLine - offset + 1);
                }
               
                // If not searching forward we will reverse the buffer for searching. Resulting line numbers will be calculated back.
                Collections.reverse(lines);
            }
View Full Code Here

             int cnt = 0;
             for(int i=10; i< labelList.size(); i++){
                Integer tmp =(Integer) ((Map) labelList.get(i)).get("compValue");
                cnt += tmp.intValue();
             }
             labelList.subList(10, labelList.size()).clear();
             Map aMap = new HashMap();
             aMap.put("label", GuiUtil.getMessage("logAnalyzerLoggers.chart.other"));
             aMap.put("compValue", new Integer(cnt));
             labelList.add(aMap);
         }
View Full Code Here

     */
    static MethodType preSpreadType(MethodType targetType, int spreadCount) {
        @SuppressWarnings("unchecked")
        ArrayList<Class<?>> params = new ArrayList(targetType.parameterList());
        int outargs = params.size();
        params.subList(outargs - spreadCount, outargs).clear();
        params.add(Object.class);
        return MethodType.methodType(targetType.returnType(), params);
    }

    MethodHandle makeInstance(MethodHandle target) {
View Full Code Here

    for (int i = 0; i < 10; i++) {
      al.add(new Integer(i));
    }
    assertTrue(
        "Sublist returned should have implemented Random Access interface",
        al.subList(3, 7) instanceof RandomAccess);

    List ll = new LinkedList();
    for (int i = 0; i < 10; i++) {
      ll.add(new Integer(i));
    }
View Full Code Here

     */
    public void test_subList_empty() {
        // Regression for HARMONY-389
        List al = new ArrayList();
        al.add("one");
        List emptySubList = al.subList(0, 0);

        try {
            emptySubList.get(0);
            fail("emptySubList.get(0) should throw IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
View Full Code Here

    public void test_subList_addAll() {
        // Regression for HARMONY-390
        List mainList = new ArrayList();
        Object[] mainObjects = { "a", "b", "c" };
        mainList.addAll(Arrays.asList(mainObjects));
        List subList = mainList.subList(1, 2);
        assertFalse("subList should not contain \"a\"", subList.contains("a"));
        assertFalse("subList should not contain \"c\"", subList.contains("c"));
        assertTrue("subList should contain \"b\"", subList.contains("b"));

        Object[] subObjects = { "one", "two", "three" };
View Full Code Here

    src.add(new Integer(6));

    // so src becomes a list like this:
    // [1, 2, 3, 1, 2, 3, 1, 2, 3, 5, 6]

    sub = new ArrayList(src.subList(3, 11));
    // [1, 2, 3, 1, 2, 3, 5, 6]
    assertEquals("TestA : Returned wrong indexOfSubList, ", 3, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(6, 11));
View Full Code Here

    sub = new ArrayList(src.subList(3, 11));
    // [1, 2, 3, 1, 2, 3, 5, 6]
    assertEquals("TestA : Returned wrong indexOfSubList, ", 3, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(6, 11));
    // [1, 2, 3, 5, 6]
    assertEquals("TestB : Returned wrong indexOfSubList, ", 6, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(0, 3));
View Full Code Here

    sub = new ArrayList(src.subList(6, 11));
    // [1, 2, 3, 5, 6]
    assertEquals("TestB : Returned wrong indexOfSubList, ", 6, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(0, 3));
    // [1, 2, 3]
    assertEquals("TestCC : Returned wrong indexOfSubList, ", 0, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(9, 11));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.