org.apache.calcite.util.Util.asIndexMapJ()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.calcite.util.Util.asIndexMapJ()方法的一些代码示例,展示了Util.asIndexMapJ()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.asIndexMapJ()方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:asIndexMapJ

Util.asIndexMapJ介绍

[英]Returns a map that is a view onto a collection of values, using the provided function to convert a value to a key.

Unlike com.google.common.collect.Maps#uniqueIndex(Iterable,com.google.common.base.Function), returns a view whose contents change as the collection of values changes.
[中]使用提供的函数将值转换为键,返回值集合的视图映射。
不像com。谷歌。常见的收集Maps#uniqueIndex(Iterable,com.google.common.base.Function)返回一个视图,其内容随着值集合的变化而变化。

代码示例

代码示例来源:origin: Qihoo360/Quicksql

@SuppressWarnings("Guava")
@Deprecated
public static <K, V> Map<K, V> asIndexMap(
  final Collection<V> values,
  final com.google.common.base.Function<V, K> function) {
 return asIndexMapJ(values, function::apply);
}

代码示例来源:origin: org.apache.calcite/calcite-core

@SuppressWarnings("Guava")
@Deprecated
public static <K, V> Map<K, V> asIndexMap(
  final Collection<V> values,
  final com.google.common.base.Function<V, K> function) {
 return asIndexMapJ(values, function::apply);
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testAsIndexView() {
 final List<String> values  = Lists.newArrayList("abCde", "X", "y");
 final Map<String, String> map =
   Util.asIndexMapJ(values, input -> input.toUpperCase(Locale.ROOT));
 assertThat(map.size(), equalTo(values.size()));
 assertThat(map.get("X"), equalTo("X"));
 assertThat(map.get("Y"), equalTo("y"));
 assertThat(map.get("y"), is((String) null));
 assertThat(map.get("ABCDE"), equalTo("abCde"));
 // If you change the values collection, the map changes.
 values.remove(1);
 assertThat(map.size(), equalTo(values.size()));
 assertThat(map.get("X"), is((String) null));
 assertThat(map.get("Y"), equalTo("y"));
}

代码示例来源:origin: org.apache.calcite/calcite-core

@Test public void testAsIndexView() {
 final List<String> values  = Lists.newArrayList("abCde", "X", "y");
 final Map<String, String> map =
   Util.asIndexMapJ(values, input -> input.toUpperCase(Locale.ROOT));
 assertThat(map.size(), equalTo(values.size()));
 assertThat(map.get("X"), equalTo("X"));
 assertThat(map.get("Y"), equalTo("y"));
 assertThat(map.get("y"), is((String) null));
 assertThat(map.get("ABCDE"), equalTo("abCde"));
 // If you change the values collection, the map changes.
 values.remove(1);
 assertThat(map.size(), equalTo(values.size()));
 assertThat(map.get("X"), is((String) null));
 assertThat(map.get("Y"), equalTo("y"));
}

相关文章