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

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(372)

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

Table.values介绍

[英]Returns a collection of all values, which may contain duplicates. Changes to the returned collection will update the underlying table, and vice versa.
[中]返回所有值的集合,这些值可能包含重复项。对返回集合的更改将更新基础表,反之亦然。

代码示例

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

  1. @Override
  2. public Collection<V> values() {
  3. return original.values();
  4. }

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

  1. @Override
  2. Collection<V2> createValues() {
  3. return Collections2.transform(fromTable.values(), function);
  4. }

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

  1. @Override
  2. public Collection<V> values() {
  3. synchronized (mutex) {
  4. return collection(delegate().values(), mutex);
  5. }
  6. }

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

  1. @Override
  2. public Collection<V> values() {
  3. synchronized (mutex) {
  4. return collection(delegate().values(), mutex);
  5. }
  6. }

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

  1. @Override
  2. public Collection<V> values() {
  3. return delegate().values();
  4. }

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

  1. @Override
  2. public Collection<V> values() {
  3. return delegate().values();
  4. }

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

  1. @Override
  2. public Collection<V> values() {
  3. assertTrue(Thread.holdsLock(mutex));
  4. /* TODO: verify that the Collection is also synchronized? */
  5. return delegate.values();
  6. }

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

  1. @Override
  2. protected Collection<String> create(String[] elements) {
  3. List<Integer> rowKeys = Lists.newArrayList();
  4. for (int i = 0; i < elements.length; i++) {
  5. rowKeys.add(i);
  6. }
  7. Table<Integer, Character, String> table =
  8. ArrayTable.create(rowKeys, ImmutableList.of('a'));
  9. populateForValues(table, elements);
  10. return table.values();
  11. }
  12. })

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

  1. @Override
  2. protected Collection<String> create(String[] elements) {
  3. Table<Integer, Character, String> table = HashBasedTable.create();
  4. for (int i = 0; i < elements.length; i++) {
  5. table.put(i, 'a', "x" + checkNotNull(elements[i]));
  6. }
  7. return Tables.transformValues(table, removeFirstCharacter).values();
  8. }
  9. })

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

  1. @Override
  2. protected Collection<String> create(String[] elements) {
  3. Table<Integer, Character, String> table = HashBasedTable.create();
  4. table.put(1, 'a', "foo");
  5. table.clear();
  6. populateForValues(table, elements);
  7. return table.values();
  8. }
  9. })

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

  1. @Override
  2. protected Collection<String> create(String[] elements) {
  3. Table<Integer, Character, String> table = TreeBasedTable.create();
  4. table.put(1, 'a', "foo");
  5. table.clear();
  6. populateForValues(table, elements);
  7. return table.values();
  8. }
  9. })

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

  1. public void testValuesToString_ordered() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. assertEquals("[a, null, c, b, null, null, null, null, null]", table.values().toString());
  4. }

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

  1. public void testValuesToString_ordered() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. assertEquals("[b, a, c]", table.values().toString());
  4. }

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

  1. @Override
  2. protected Collection<String> create(String[] elements) {
  3. Table<Integer, Character, String> table = HashBasedTable.create();
  4. table.put(1, 'a', "foo");
  5. table.clear();
  6. populateForValues(table, elements);
  7. return Tables.unmodifiableTable(table).values();
  8. }
  9. })

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

  1. private static <R, C, V> void validateViewOrdering(Table<R, C, V> original, Table<R, C, V> copy) {
  2. assertThat(copy.cellSet()).containsExactlyElementsIn(original.cellSet()).inOrder();
  3. assertThat(copy.rowKeySet()).containsExactlyElementsIn(original.rowKeySet()).inOrder();
  4. assertThat(copy.values()).containsExactlyElementsIn(original.values()).inOrder();
  5. }

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

  1. public void testIterationOrder() {
  2. Table<String, String, String> table = HashBasedTable.create();
  3. for (int i = 0; i < 5; i++) {
  4. table.put("r" + i, "c" + i, "v" + i);
  5. }
  6. assertThat(table.rowKeySet()).containsExactly("r0", "r1", "r2", "r3", "r4").inOrder();
  7. assertThat(table.columnKeySet()).containsExactly("c0", "c1", "c2", "c3", "c4").inOrder();
  8. assertThat(table.values()).containsExactly("v0", "v1", "v2", "v3", "v4").inOrder();
  9. }

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

  1. public void testBuilder_orderRowsAndColumnsBy_putAll() {
  2. Table<Character, Integer, String> table = HashBasedTable.create();
  3. table.put('b', 2, "foo");
  4. table.put('b', 1, "bar");
  5. table.put('a', 2, "baz");
  6. ImmutableTable.Builder<Character, Integer, String> builder = ImmutableTable.builder();
  7. Table<Character, Integer, String> copy =
  8. builder
  9. .orderRowsBy(Ordering.natural())
  10. .orderColumnsBy(Ordering.natural())
  11. .putAll(table)
  12. .build();
  13. assertThat(copy.rowKeySet()).containsExactly('a', 'b').inOrder();
  14. assertThat(copy.columnKeySet()).containsExactly(1, 2).inOrder();
  15. assertThat(copy.values()).containsExactly("baz", "bar", "foo").inOrder();
  16. assertThat(copy.row('b').keySet()).containsExactly(1, 2).inOrder();
  17. }

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

  1. public void testBuilder_orderRowsAndColumnsBy_dense() {
  2. ImmutableTable.Builder<Character, Integer, String> builder = ImmutableTable.builder();
  3. builder.orderRowsBy(Ordering.natural());
  4. builder.orderColumnsBy(Ordering.natural());
  5. builder.put('c', 3, "foo");
  6. builder.put('c', 2, "bar");
  7. builder.put('c', 1, "baz");
  8. builder.put('b', 3, "cat");
  9. builder.put('b', 1, "dog");
  10. builder.put('a', 3, "foo");
  11. builder.put('a', 2, "bar");
  12. builder.put('a', 1, "baz");
  13. Table<Character, Integer, String> table = builder.build();
  14. assertThat(table.rowKeySet()).containsExactly('a', 'b', 'c').inOrder();
  15. assertThat(table.columnKeySet()).containsExactly(1, 2, 3).inOrder();
  16. assertThat(table.values())
  17. .containsExactly("baz", "bar", "foo", "dog", "cat", "baz", "bar", "foo")
  18. .inOrder();
  19. assertThat(table.row('c').keySet()).containsExactly(1, 2, 3).inOrder();
  20. assertThat(table.column(1).keySet()).containsExactly('a', 'b', 'c').inOrder();
  21. }

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

  1. public void testBuilder_orderRowsAndColumnsBy_sparse() {
  2. ImmutableTable.Builder<Character, Integer, String> builder = ImmutableTable.builder();
  3. builder.orderRowsBy(Ordering.natural());
  4. builder.orderColumnsBy(Ordering.natural());
  5. builder.put('x', 2, "foo");
  6. builder.put('r', 1, "bar");
  7. builder.put('c', 3, "baz");
  8. builder.put('b', 7, "cat");
  9. builder.put('e', 5, "dog");
  10. builder.put('c', 0, "axe");
  11. builder.put('e', 3, "tub");
  12. builder.put('r', 4, "foo");
  13. builder.put('x', 5, "bar");
  14. Table<Character, Integer, String> table = builder.build();
  15. assertThat(table.rowKeySet()).containsExactly('b', 'c', 'e', 'r', 'x').inOrder();
  16. assertThat(table.columnKeySet()).containsExactly(0, 1, 2, 3, 4, 5, 7).inOrder();
  17. assertThat(table.values())
  18. .containsExactly("cat", "axe", "baz", "tub", "dog", "bar", "foo", "foo", "bar")
  19. .inOrder();
  20. assertThat(table.row('c').keySet()).containsExactly(0, 3).inOrder();
  21. assertThat(table.column(5).keySet()).containsExactly('e', 'x').inOrder();
  22. }

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

  1. public void testTransposedViews() {
  2. Table<Integer, String, Character> original = HashBasedTable.create();
  3. Table<String, Integer, Character> transpose = Tables.transpose(original);
  4. original.put(1, "foo", 'a');
  5. assertSame(original.columnKeySet(), transpose.rowKeySet());
  6. assertSame(original.rowKeySet(), transpose.columnKeySet());
  7. assertSame(original.columnMap(), transpose.rowMap());
  8. assertSame(original.rowMap(), transpose.columnMap());
  9. assertSame(original.values(), transpose.values());
  10. assertEquals(original.row(1), transpose.column(1));
  11. assertEquals(original.row(2), transpose.column(2));
  12. assertEquals(original.column("foo"), transpose.row("foo"));
  13. assertEquals(original.column("bar"), transpose.row("bar"));
  14. }
  15. }

相关文章