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

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

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

Table.rowKeySet介绍

[英]Returns a set of row keys that have one or more values in the table. Changes to the set will update the underlying table, and vice versa.
[中]返回一组在表中有一个或多个值的行键。对集合的更改将更新基础表,反之亦然。

代码示例

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

  1. @Override
  2. public Set<R> rowKeySet() {
  3. return fromTable.rowKeySet();
  4. }

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

  1. @Override
  2. public Set<R> columnKeySet() {
  3. return original.rowKeySet();
  4. }

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

  1. @Override
  2. public Set<R> rowKeySet() {
  3. return delegate().rowKeySet();
  4. }

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

  1. @Override
  2. public Set<R> rowKeySet() {
  3. assertTrue(Thread.holdsLock(mutex));
  4. return delegate.rowKeySet();
  5. }

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

  1. @Override
  2. public Set<R> rowKeySet() {
  3. synchronized (mutex) {
  4. return set(delegate().rowKeySet(), mutex);
  5. }
  6. }

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

  1. private ArrayTable(Table<R, C, V> table) {
  2. this(table.rowKeySet(), table.columnKeySet());
  3. putAll(table);
  4. }

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

  1. @Override
  2. protected Set<String> create(String[] elements) {
  3. Table<String, Integer, Character> table = HashBasedTable.create();
  4. populateForRowKeySet(table, elements);
  5. return table.rowKeySet();
  6. }
  7. })

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

  1. @Override
  2. protected Set<String> create(String[] elements) {
  3. Table<String, Integer, Character> table =
  4. ArrayTable.create(ImmutableList.copyOf(elements), ImmutableList.of(1, 2));
  5. populateForRowKeySet(table, elements);
  6. return table.rowKeySet();
  7. }
  8. })

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

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

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

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

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

  1. @Override
  2. protected Set<String> create(String[] elements) {
  3. Table<String, Integer, Character> table = HashBasedTable.create();
  4. populateForRowKeySet(table, elements);
  5. return Tables.unmodifiableTable(table).rowKeySet();
  6. }
  7. })

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

  1. public void testCreateExplicitComparators() {
  2. table = TreeBasedTable.create(Collections.reverseOrder(), Ordering.usingToString());
  3. table.put("foo", 3, 'a');
  4. table.put("foo", 12, 'b');
  5. table.put("bar", 5, 'c');
  6. table.put("cat", 8, 'd');
  7. assertThat(table.rowKeySet()).containsExactly("foo", "cat", "bar").inOrder();
  8. assertThat(table.row("foo").keySet()).containsExactly(12, 3).inOrder();
  9. }

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

  1. public void testRowKeySetOrdering() {
  2. table = create("foo", 3, 'a', "bar", 1, 'b', "foo", 2, 'c');
  3. assertThat(table.rowKeySet()).containsExactly("foo", "bar").inOrder();
  4. }

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

  1. public void testCreateCopyArrayTable() {
  2. Table<String, Integer, Character> original =
  3. create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  4. Table<String, Integer, Character> copy = ArrayTable.create(original);
  5. assertEquals(original, copy);
  6. original.put("foo", 1, 'd');
  7. assertEquals((Character) 'd', original.get("foo", 1));
  8. assertEquals((Character) 'a', copy.get("foo", 1));
  9. assertEquals(copy.rowKeySet(), original.rowKeySet());
  10. assertEquals(copy.columnKeySet(), original.columnKeySet());
  11. }

代码示例来源: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. private static <R, C, V> void validateReserialization(Table<R, C, V> original) {
  2. Table<R, C, V> copy = SerializableTester.reserializeAndAssert(original);
  3. assertThat(copy.cellSet()).containsExactlyElementsIn(original.cellSet()).inOrder();
  4. assertThat(copy.rowKeySet()).containsExactlyElementsIn(original.rowKeySet()).inOrder();
  5. assertThat(copy.columnKeySet()).containsExactlyElementsIn(original.columnKeySet()).inOrder();
  6. }

代码示例来源: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 testCreateCopy() {
  2. TreeBasedTable<String, Integer, Character> original =
  3. TreeBasedTable.create(Collections.reverseOrder(), Ordering.usingToString());
  4. original.put("foo", 3, 'a');
  5. original.put("foo", 12, 'b');
  6. original.put("bar", 5, 'c');
  7. original.put("cat", 8, 'd');
  8. table = TreeBasedTable.create(original);
  9. assertThat(table.rowKeySet()).containsExactly("foo", "cat", "bar").inOrder();
  10. assertThat(table.row("foo").keySet()).containsExactly(12, 3).inOrder();
  11. assertEquals(original, table);
  12. }

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

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

代码示例来源: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. }

相关文章