当前位置: 首页>>代码示例>>Java>>正文


Java Lists类代码示例

本文整理汇总了Java中java8.util.Lists的典型用法代码示例。如果您正苦于以下问题:Java Lists类的具体用法?Java Lists怎么用?Java Lists使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Lists类属于java8.util包,在下文中一共展示了Lists类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: end

import java8.util.Lists; //导入依赖的package包/类
@Override
public void end() {
    Lists.sort(list, comparator);
    downstream.begin(list.size());
    if (!cancellationWasRequested) {
        Iterables.forEach(list, downstream::accept);
    } else {
        for (T t : list) {
            if (downstream.cancellationRequested()) {
                break;
            }
            downstream.accept(t);
        }
    }
    downstream.end();
    list = null;
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:18,代码来源:SortedOps.java

示例2: testOpWithNullSorted

import java8.util.Lists; //导入依赖的package包/类
@Test(dataProvider = "withNull:StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testOpWithNullSorted(String name, TestData.OfRef<Integer> data) {
    List<Integer> l = new ArrayList<>();
    Lists.sort(data.into(l), cNullInteger);
    // Need to inject SORTED into the sorted list source since
    // sorted() with a comparator ironically clears SORTED
    Collection<Integer> node = exerciseOps(new SortedTestData<>(l), Stream::distinct);
    assertUnique(node);
    assertSorted(node, cNullInteger);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:11,代码来源:DistinctOpTest.java

示例3: ensureArrayCannotModifyList

import java8.util.Lists; //导入依赖的package包/类
@Test
public void ensureArrayCannotModifyList() {
    String[] array = stringArray.clone();
    List<String> list = Lists.of(array);
    array[0] = "xyzzy";
    assertEquals(list, Arrays.asList(stringArray));
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:8,代码来源:ListFactories.java

示例4: copyOfResultsEqual

import java8.util.Lists; //导入依赖的package包/类
@Test
public void copyOfResultsEqual() {
    List<Integer> orig = genList();
    List<Integer> copy = Lists.copyOf(orig);

    assertEquals(orig, copy);
    assertEquals(copy, orig);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:9,代码来源:ListFactories.java

示例5: copyOfModifiedUnequal

import java8.util.Lists; //导入依赖的package包/类
@Test
public void copyOfModifiedUnequal() {
    List<Integer> orig = genList();
    List<Integer> copy = Lists.copyOf(orig);
    orig.add(4);

    assertNotEquals(orig, copy);
    assertNotEquals(copy, orig);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:10,代码来源:ListFactories.java

示例6: copyOfIdentity

import java8.util.Lists; //导入依赖的package包/类
@Test
public void copyOfIdentity() {
    List<Integer> orig = genList();
    List<Integer> copy1 = Lists.copyOf(orig);
    List<Integer> copy2 = Lists.copyOf(copy1);

    assertNotSame(orig, copy1);
    assertSame(copy1, copy2);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:10,代码来源:ListFactories.java

示例7: empty

import java8.util.Lists; //导入依赖的package包/类
@DataProvider(name="empty")
public Iterator<Object[]> empty() {
    return Collections.singletonList(
        a(Lists.of(), Collections.emptyList())
    ).iterator();
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:7,代码来源:ListFactories.java

示例8: nonempty

import java8.util.Lists; //导入依赖的package包/类
@DataProvider(name="nonempty")
public Iterator<Object[]> nonempty() {
    return asList(
        a(Lists2.of("a"),
           asList("a")),
        a(Lists2.of("a", "b"),
           asList("a", "b")),
        a(Lists2.of("a", "b", "c"),
           asList("a", "b", "c")),
        a(Lists2.of("a", "b", "c", "d"),
           asList("a", "b", "c", "d")),
        a(Lists2.of("a", "b", "c", "d", "e"),
           asList("a", "b", "c", "d", "e")),
        a(Lists2.of("a", "b", "c", "d", "e", "f"),
           asList("a", "b", "c", "d", "e", "f")),
        a(Lists2.of("a", "b", "c", "d", "e", "f", "g"),
           asList("a", "b", "c", "d", "e", "f", "g")),
        a(Lists2.of("a", "b", "c", "d", "e", "f", "g", "h"),
           asList("a", "b", "c", "d", "e", "f", "g", "h")),
        a(Lists2.of("a", "b", "c", "d", "e", "f", "g", "h", "i"),
           asList("a", "b", "c", "d", "e", "f", "g", "h", "i")),
        a(Lists2.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
           asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")),
        a(Lists2.of(stringArray),
           asList(stringArray)),
        a(Lists.of("a"),
           asList("a")),
        a(Lists.of("a", "b"),
           asList("a", "b")),
        a(Lists.of("a", "b", "c"),
           asList("a", "b", "c")),
        a(Lists.of("a", "b", "c", "d"),
           asList("a", "b", "c", "d")),
        a(Lists.of("a", "b", "c", "d", "e"),
           asList("a", "b", "c", "d", "e")),
        a(Lists.of("a", "b", "c", "d", "e", "f"),
           asList("a", "b", "c", "d", "e", "f")),
        a(Lists.of("a", "b", "c", "d", "e", "f", "g"),
           asList("a", "b", "c", "d", "e", "f", "g")),
        a(Lists.of("a", "b", "c", "d", "e", "f", "g", "h"),
           asList("a", "b", "c", "d", "e", "f", "g", "h")),
        a(Lists.of("a", "b", "c", "d", "e", "f", "g", "h", "i"),
           asList("a", "b", "c", "d", "e", "f", "g", "h", "i")),
        a(Lists.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"),
           asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")),
        a(Lists.of(stringArray),
           asList(stringArray))
    ).iterator();
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:50,代码来源:ListFactories.java

示例9: nullDisallowed1

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed1() {
    Lists.of((Object) null); // force one-arg overload
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例10: nullDisallowed2a

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2a() {
    Lists.of("a", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例11: nullDisallowed2b

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2b() {
    Lists.of(null, "b");
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例12: nullDisallowed3

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed3() {
    Lists.of("a", "b", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例13: nullDisallowed4

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed4() {
    Lists.of("a", "b", "c", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例14: nullDisallowed5

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed5() {
    Lists.of("a", "b", "c", "d", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java

示例15: nullDisallowed6

import java8.util.Lists; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed6() {
    Lists.of("a", "b", "c", "d", "e", null);
}
 
开发者ID:streamsupport,项目名称:streamsupport,代码行数:5,代码来源:ListFactories.java


注:本文中的java8.util.Lists类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。