本文整理了Java中org.apache.calcite.util.Util.distinctList()
方法的一些代码示例,展示了Util.distinctList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.distinctList()
方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:distinctList
[英]Converts an iterable into a list with unique elements.
The order is preserved; the second and subsequent occurrences are removed.
If iterable is a unique list it is returned unchanged.
[中]将iterable转换为具有唯一元素的列表。
秩序得以维持;将删除第二个和后续的引用。
如果iterable是一个唯一的列表,那么它将原封不动地返回。
代码示例来源:origin: Qihoo360/Quicksql
/** Returns whether one of a list of collations indicates that the collection
* is sorted on the given list of keys. */
public static boolean contains(List<RelCollation> collations,
ImmutableIntList keys) {
final List<Integer> distinctKeys = Util.distinctList(keys);
for (RelCollation collation : collations) {
if (contains(collation, distinctKeys)) {
return true;
}
}
return false;
}
代码示例来源:origin: Qihoo360/Quicksql
/** Returns whether a collation indicates that the collection is sorted on
* a given list of keys.
*
* @param collation Collation
* @param keys List of keys
* @return Whether the collection is sorted on the given keys
*/
public static boolean contains(RelCollation collation,
Iterable<Integer> keys) {
return contains(collation, Util.distinctList(keys));
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Returns whether one of a list of collations indicates that the collection
* is sorted on the given list of keys. */
public static boolean contains(List<RelCollation> collations,
ImmutableIntList keys) {
final List<Integer> distinctKeys = Util.distinctList(keys);
for (RelCollation collation : collations) {
if (contains(collation, distinctKeys)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Returns whether a collation indicates that the collection is sorted on
* a given list of keys.
*
* @param collation Collation
* @param keys List of keys
* @return Whether the collection is sorted on the given keys
*/
public static boolean contains(RelCollation collation,
Iterable<Integer> keys) {
return contains(collation, Util.distinctList(keys));
}
代码示例来源:origin: Qihoo360/Quicksql
/** Unit test for {@link Util#distinctList(List)}
* and {@link Util#distinctList(Iterable)}. */
@Test public void testDistinctList() {
assertThat(Util.distinctList(Arrays.asList(1, 2)), is(Arrays.asList(1, 2)));
assertThat(Util.distinctList(Arrays.asList(1, 2, 1)),
is(Arrays.asList(1, 2)));
try {
List<Object> o = Util.distinctList(null);
fail("expected exception, got " + o);
} catch (NullPointerException ignore) {
}
final List<Integer> empty = ImmutableList.of();
assertThat(Util.distinctList(empty), sameInstance(empty));
final Iterable<Integer> emptyIterable = empty;
assertThat(Util.distinctList(emptyIterable), sameInstance(emptyIterable));
final List<Integer> empty2 = ImmutableList.of();
assertThat(Util.distinctList(empty2), sameInstance(empty2));
final List<String> abc = ImmutableList.of("a", "b", "c");
assertThat(Util.distinctList(abc), sameInstance(abc));
final List<String> a = ImmutableList.of("a");
assertThat(Util.distinctList(a), sameInstance(a));
final List<String> cbca = ImmutableList.of("c", "b", "c", "a");
assertThat(Util.distinctList(cbca), not(sameInstance(cbca)));
assertThat(Util.distinctList(cbca), is(Arrays.asList("c", "b", "a")));
final Collection<String> cbcaC = new LinkedHashSet<>(cbca);
assertThat(Util.distinctList(cbcaC), not(sameInstance(cbca)));
assertThat(Util.distinctList(cbcaC), is(Arrays.asList("c", "b", "a")));
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Unit test for {@link Util#distinctList(List)}
* and {@link Util#distinctList(Iterable)}. */
@Test public void testDistinctList() {
assertThat(Util.distinctList(Arrays.asList(1, 2)), is(Arrays.asList(1, 2)));
assertThat(Util.distinctList(Arrays.asList(1, 2, 1)),
is(Arrays.asList(1, 2)));
try {
List<Object> o = Util.distinctList(null);
fail("expected exception, got " + o);
} catch (NullPointerException ignore) {
}
final List<Integer> empty = ImmutableList.of();
assertThat(Util.distinctList(empty), sameInstance(empty));
final Iterable<Integer> emptyIterable = empty;
assertThat(Util.distinctList(emptyIterable), sameInstance(emptyIterable));
final List<Integer> empty2 = ImmutableList.of();
assertThat(Util.distinctList(empty2), sameInstance(empty2));
final List<String> abc = ImmutableList.of("a", "b", "c");
assertThat(Util.distinctList(abc), sameInstance(abc));
final List<String> a = ImmutableList.of("a");
assertThat(Util.distinctList(a), sameInstance(a));
final List<String> cbca = ImmutableList.of("c", "b", "c", "a");
assertThat(Util.distinctList(cbca), not(sameInstance(cbca)));
assertThat(Util.distinctList(cbca), is(Arrays.asList("c", "b", "a")));
final Collection<String> cbcaC = new LinkedHashSet<>(cbca);
assertThat(Util.distinctList(cbcaC), not(sameInstance(cbca)));
assertThat(Util.distinctList(cbcaC), is(Arrays.asList("c", "b", "a")));
}
内容来源于网络,如有侵权,请联系作者删除!