當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。