Package java.util

Examples of java.util.ArrayList.subList()


    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


  public static void save(IDialogSettings settings, String key, Combo combo) {
    List history = new ArrayList(Arrays.asList(combo.getItems()));
    history.remove(combo.getText());
    history.add(0, combo.getText());
    if (history.size() > HISTORY_LIMIT) {
      history = history.subList(0, HISTORY_LIMIT);
    }
    settings.put(key, (String[]) history.toArray(new String[0]));
  }

}
View Full Code Here

    new Support_ListTest("", alist).runTest();

    ArrayList subList = new ArrayList();
    for (int i = -50; i < 150; i++)
      subList.add(new Integer(i));
    new Support_ListTest("", subList.subList(50, 150)).runTest();
  }

  /**
   * @tests java.util.ArrayList#ArrayList(int)
   */
 
View Full Code Here

      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

                toPrefetch = owners;
                prefetchingAll = true;
            }
            else
            {
                toPrefetch = owners.subList(0, _limit);
                prefetchingAll = false;
            }

            final Class saveClassToPrefetch = classToPrefetch;
            classToPrefetch = prefetcher.getItemClassDescriptor().getClassOfObject();
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

    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));
    // [5, 6]
    assertEquals("TestD : Returned wrong indexOfSubList, ", 9, Collections
        .indexOfSubList(src, sub));

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

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

    sub = new ArrayList(src.subList(10, 11));
    // [6]
    assertEquals("TestE : Returned wrong indexOfSubList, ", 10, Collections
        .indexOfSubList(src, sub));

    sub = new ArrayList(src.subList(0, 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.