当前位置: 首页>>代码示例>>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;未经允许,请勿转载。