當前位置: 首頁>>代碼示例>>Java>>正文


Java CopyOnWriteArrayList.subList方法代碼示例

本文整理匯總了Java中java.util.concurrent.CopyOnWriteArrayList.subList方法的典型用法代碼示例。如果您正苦於以下問題:Java CopyOnWriteArrayList.subList方法的具體用法?Java CopyOnWriteArrayList.subList怎麽用?Java CopyOnWriteArrayList.subList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.CopyOnWriteArrayList的用法示例。


在下文中一共展示了CopyOnWriteArrayList.subList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSubList

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * sublists contains elements at indexes offset from their base
 */
public void testSubList() {
    CopyOnWriteArrayList a = populatedArray(10);
    assertTrue(a.subList(1,1).isEmpty());
    for (int j = 0; j < 9; ++j) {
        for (int i = j ; i < 10; ++i) {
            List b = a.subList(j,i);
            for (int k = j; k < i; ++k) {
                assertEquals(new Integer(k), b.get(k-j));
            }
        }
    }

    List s = a.subList(2, 5);
    assertEquals(3, s.size());
    s.set(2, m1);
    assertEquals(a.get(4), m1);
    s.clear();
    assertEquals(7, a.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:CopyOnWriteArrayListTest.java

示例2: testGet1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * get throws an IndexOutOfBoundsException on a negative index
 */
public void testGet1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.get(-1);
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例3: testGet2_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * get throws an IndexOutOfBoundsException on a too high index
 */
public void testGet2_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.get(list.size());
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例4: testSet1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * set throws an IndexOutOfBoundsException on a negative index
 */
public void testSet1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.set(-1, "qwerty");
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例5: testSet2

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * set throws an IndexOutOfBoundsException on a too high index
 */
public void testSet2() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.set(list.size(), "qwerty");
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例6: testAdd1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * add throws an IndexOutOfBoundsException on a negative index
 */
public void testAdd1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.add(-1, "qwerty");
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例7: testAdd2_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * add throws an IndexOutOfBoundsException on a too high index
 */
public void testAdd2_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.add(list.size() + 1, "qwerty");
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例8: testRemove1_IndexOutOfBounds

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * remove throws an IndexOutOfBoundsException on a negative index
 */
public void testRemove1_IndexOutOfBounds() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.remove(-1);
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例9: testRemove2_IndexOutOfBounds

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * remove throws an IndexOutOfBoundsException on a too high index
 */
public void testRemove2_IndexOutOfBounds() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.remove(list.size());
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例10: testAddAll1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * addAll throws an IndexOutOfBoundsException on a negative index
 */
public void testAddAll1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.addAll(-1, new LinkedList());
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例11: testAddAll2_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * addAll throws an IndexOutOfBoundsException on a too high index
 */
public void testAddAll2_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.addAll(list.size() + 1, new LinkedList());
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例12: testListIterator1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * listIterator throws an IndexOutOfBoundsException on a negative index
 */
public void testListIterator1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.listIterator(-1);
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例13: testListIterator2_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * listIterator throws an IndexOutOfBoundsException on a too high index
 */
public void testListIterator2_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.listIterator(list.size() + 1);
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例14: testSubList1_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * subList throws an IndexOutOfBoundsException on a negative index
 */
public void testSubList1_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.subList(-1, list.size());
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java

示例15: testSubList2_IndexOutOfBoundsException

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * subList throws an IndexOutOfBoundsException on a too high index
 */
public void testSubList2_IndexOutOfBoundsException() {
    CopyOnWriteArrayList c = populatedArray(5);
    List[] lists = { c, c.subList(1, c.size() - 1) };
    for (List list : lists) {
        try {
            list.subList(0, list.size() + 1);
            shouldThrow();
        } catch (IndexOutOfBoundsException success) {}
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:CopyOnWriteArrayListTest.java


注:本文中的java.util.concurrent.CopyOnWriteArrayList.subList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。