com.google.common.collect.Maps.indexMap()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(171)

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

Maps.indexMap介绍

[英]Returns a map from the ith element of list to i.
[中]返回从列表的第i个元素到i的映射。

代码示例

代码示例来源:origin: google/guava

ExplicitOrdering(List<T> valuesInOrder) {
 this(Maps.indexMap(valuesInOrder));
}

代码示例来源:origin: google/j2objc

ExplicitOrdering(List<T> valuesInOrder) {
 this(Maps.indexMap(valuesInOrder));
}

代码示例来源:origin: google/guava

PowerSet(Set<E> input) {
 checkArgument(
   input.size() <= 30, "Too many elements to create power set: %s > 30", input.size());
 this.inputSet = Maps.indexMap(input);
}

代码示例来源:origin: wildfly/wildfly

ExplicitOrdering(List<T> valuesInOrder) {
 this(Maps.indexMap(valuesInOrder));
}

代码示例来源:origin: google/j2objc

PowerSet(Set<E> input) {
 this.inputSet = Maps.indexMap(input);
 checkArgument(
   inputSet.size() <= 30, "Too many elements to create power set: %s > 30", inputSet.size());
}

代码示例来源:origin: google/guava

private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
 this.rowList = ImmutableList.copyOf(rowKeys);
 this.columnList = ImmutableList.copyOf(columnKeys);
 checkArgument(rowList.isEmpty() == columnList.isEmpty());
 /*
  * TODO(jlevy): Support only one of rowKey / columnKey being empty? If we
  * do, when columnKeys is empty but rowKeys isn't, rowKeyList() can contain
  * elements but rowKeySet() will be empty and containsRow() won't
  * acknolwedge them.
  */
 rowKeyToIndex = Maps.indexMap(rowList);
 columnKeyToIndex = Maps.indexMap(columnList);
 @SuppressWarnings("unchecked")
 V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()];
 array = tmpArray;
 // Necessary because in GWT the arrays are initialized with "undefined" instead of null.
 eraseAll();
}

代码示例来源:origin: google/j2objc

private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
 this.rowList = ImmutableList.copyOf(rowKeys);
 this.columnList = ImmutableList.copyOf(columnKeys);
 checkArgument(rowList.isEmpty() == columnList.isEmpty());
 /*
  * TODO(jlevy): Support only one of rowKey / columnKey being empty? If we
  * do, when columnKeys is empty but rowKeys isn't, rowKeyList() can contain
  * elements but rowKeySet() will be empty and containsRow() won't
  * acknolwedge them.
  */
 rowKeyToIndex = Maps.indexMap(rowList);
 columnKeyToIndex = Maps.indexMap(columnList);
 @SuppressWarnings("unchecked")
 V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()];
 array = tmpArray;
 // Necessary because in GWT the arrays are initialized with "undefined" instead of null.
 eraseAll();
}

代码示例来源:origin: google/guava

ImmutableSet<R> rowSpace,
 ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {

代码示例来源:origin: wildfly/wildfly

private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
 this.rowList = ImmutableList.copyOf(rowKeys);
 this.columnList = ImmutableList.copyOf(columnKeys);
 checkArgument(rowList.isEmpty() == columnList.isEmpty());
 /*
  * TODO(jlevy): Support only one of rowKey / columnKey being empty? If we
  * do, when columnKeys is empty but rowKeys isn't, rowKeyList() can contain
  * elements but rowKeySet() will be empty and containsRow() won't
  * acknolwedge them.
  */
 rowKeyToIndex = Maps.indexMap(rowList);
 columnKeyToIndex = Maps.indexMap(columnList);
 @SuppressWarnings("unchecked")
 V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()];
 array = tmpArray;
 // Necessary because in GWT the arrays are initialized with "undefined" instead of null.
 eraseAll();
}

代码示例来源:origin: google/guava

@Override
 SerializedForm createSerializedForm() {
  Map<C, Integer> columnKeyToIndex = Maps.indexMap(columnKeySet());
  int[] cellColumnIndices = new int[cellSet().size()];
  int i = 0;
  for (Cell<R, C, V> cell : cellSet()) {
   cellColumnIndices[i++] = columnKeyToIndex.get(cell.getColumnKey());
  }
  return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
 }
}

代码示例来源:origin: wildfly/wildfly

PowerSet(Set<E> input) {
 this.inputSet = Maps.indexMap(input);
 checkArgument(
   inputSet.size() <= 30, "Too many elements to create power set: %s > 30", inputSet.size());
}

代码示例来源:origin: google/guava

V[][] array = (V[][]) new Object[rowSpace.size()][columnSpace.size()];
this.values = array;
this.rowKeyToIndex = Maps.indexMap(rowSpace);
this.columnKeyToIndex = Maps.indexMap(columnSpace);
rowCounts = new int[rowKeyToIndex.size()];
columnCounts = new int[columnKeyToIndex.size()];

代码示例来源:origin: google/j2objc

ImmutableSet<R> rowSpace,
 ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {

代码示例来源:origin: google/guava

final ImmutableMap<E, Integer> index = Maps.indexMap(set);
checkNonnegative(size, "size");
checkArgument(size <= index.size(), "size (%s) must be <= set.size() (%s)", size, index.size());

代码示例来源:origin: google/j2objc

@Override
 SerializedForm createSerializedForm() {
  Map<C, Integer> columnKeyToIndex = Maps.indexMap(columnKeySet());
  int[] cellColumnIndices = new int[cellSet().size()];
  int i = 0;
  for (Cell<R, C, V> cell : cellSet()) {
   cellColumnIndices[i++] = columnKeyToIndex.get(cell.getColumnKey());
  }
  return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
 }
}

代码示例来源:origin: google/j2objc

final ImmutableMap<E, Integer> index = Maps.indexMap(set);
checkNonnegative(size, "size");
checkArgument(size <= index.size(), "size (%s) must be <= set.size() (%s)", size, index.size());

代码示例来源:origin: google/j2objc

V[][] array = (V[][]) new Object[rowSpace.size()][columnSpace.size()];
this.values = array;
this.rowKeyToIndex = Maps.indexMap(rowSpace);
this.columnKeyToIndex = Maps.indexMap(columnSpace);
rowCounts = new int[rowKeyToIndex.size()];
columnCounts = new int[columnKeyToIndex.size()];

代码示例来源:origin: wildfly/wildfly

ImmutableSet<R> rowSpace,
 ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {

代码示例来源:origin: wildfly/wildfly

@Override
 SerializedForm createSerializedForm() {
  Map<C, Integer> columnKeyToIndex = Maps.indexMap(columnKeySet());
  int[] cellColumnIndices = new int[cellSet().size()];
  int i = 0;
  for (Cell<R, C, V> cell : cellSet()) {
   cellColumnIndices[i++] = columnKeyToIndex.get(cell.getColumnKey());
  }
  return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
 }
}

代码示例来源:origin: wildfly/wildfly

V[][] array = (V[][]) new Object[rowSpace.size()][columnSpace.size()];
this.values = array;
this.rowKeyToIndex = Maps.indexMap(rowSpace);
this.columnKeyToIndex = Maps.indexMap(columnSpace);
rowCounts = new int[rowKeyToIndex.size()];
columnCounts = new int[columnKeyToIndex.size()];

相关文章