Package java.util

Examples of java.util.ArrayList.subList()


            if (userList.size() > numberPerPage)
            {
                int numberOfPages = (int) ((userList.size() - 1 + numberPerPage) / numberPerPage);
                int from = (currentPage - 1) * numberPerPage;
                int to = Math.min(currentPage * numberPerPage,userList.size());
                context.put(SecurityConstants.CONTEXT_USERS, userList.subList(from, to));

                //now build a set of links to access each page (assumed we will show all links)
                StringBuffer pageLinks = new StringBuffer("page: ");
                for (int i = 1; i <= numberOfPages; i++)
                {
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

            if (userList.size() > numberPerPage)
            {
                int numberOfPages = (int) ((userList.size() - 1 + numberPerPage) / numberPerPage);
                int from = (currentPage - 1) * numberPerPage;
                int to = Math.min(currentPage * numberPerPage,userList.size());
                context.put(SecurityConstants.CONTEXT_USERS, userList.subList(from, to));

                //now build a set of links to access each page (assumed we will show all links)
                StringBuffer pageLinks = new StringBuffer("page: ");
                for (int i = 1; i <= numberOfPages; i++)
                {
View Full Code Here

            if (userList.size() > numberPerPage)
            {
                int numberOfPages = (int) ((userList.size() - 1 + numberPerPage) / numberPerPage);
                int from = (currentPage - 1) * numberPerPage;
                int to = Math.min(currentPage * numberPerPage,userList.size());
                context.put(SecurityConstants.CONTEXT_USERS, userList.subList(from, to));

                //now build a set of links to access each page (assumed we will show all links)
                StringBuffer pageLinks = new StringBuffer("page: ");
                for (int i = 1; i <= numberOfPages; i++)
                {
View Full Code Here

      list.add(iter.next());
    }
    if (!indexedList) {
      if (list.size() > (endIdx-startIdx)) {
        // Iterator hasn't restricted what is returned so do the index range restriction here
        return list.subList(startIdx, endIdx);
      }
    }
    return list;
  }
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

    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

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.