本文整理匯總了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;
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例7: empty
import java8.util.Lists; //導入依賴的package包/類
@DataProvider(name="empty")
public Iterator<Object[]> empty() {
return Collections.singletonList(
a(Lists.of(), Collections.emptyList())
).iterator();
}
示例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();
}
示例9: nullDisallowed1
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed1() {
Lists.of((Object) null); // force one-arg overload
}
示例10: nullDisallowed2a
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2a() {
Lists.of("a", null);
}
示例11: nullDisallowed2b
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed2b() {
Lists.of(null, "b");
}
示例12: nullDisallowed3
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed3() {
Lists.of("a", "b", null);
}
示例13: nullDisallowed4
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed4() {
Lists.of("a", "b", "c", null);
}
示例14: nullDisallowed5
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed5() {
Lists.of("a", "b", "c", "d", null);
}
示例15: nullDisallowed6
import java8.util.Lists; //導入依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void nullDisallowed6() {
Lists.of("a", "b", "c", "d", "e", null);
}