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

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

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

Table.contains介绍

[英]Returns true if the table contains a mapping with the specified row and column keys.
[中]如果表包含具有指定行键和列键的映射,则返回true。

代码示例

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. return fromTable.contains(rowKey, columnKey);
  4. }

代码示例来源:origin: guoguibing/librec

  1. /**
  2. * Get a value at entry (row, col)
  3. *
  4. * @param row row index
  5. * @param col column index
  6. * @return value at entry (row, col)
  7. */
  8. public boolean contains(int row, int col) {
  9. return data.contains(row, col) || data.contains(col, row);
  10. }

代码示例来源:origin: SonarSource/sonarqube

  1. private boolean contains(String name, String language) {
  2. return table.contains(name, language);
  3. }

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. return fromTable.contains(rowKey, columnKey);
  4. }

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. return delegate().contains(rowKey, columnKey);
  4. }

代码示例来源:origin: guoguibing/librec

  1. /**
  2. * @param id
  3. * @return
  4. */
  5. public double get(int id) {
  6. if(table.contains(0, id)){
  7. double value = table.get(0, id);
  8. return value;
  9. }
  10. else {
  11. return -1;
  12. }
  13. }

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. return delegate().contains(rowKey, columnKey);
  4. }

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. assertTrue(Thread.holdsLock(mutex));
  4. return delegate.contains(rowKey, columnKey);
  5. }

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

  1. @Override
  2. public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
  3. return original.contains(columnKey, rowKey);
  4. }

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

  1. @Override
  2. public boolean contains(Object rowKey, Object columnKey) {
  3. return delegate().contains(rowKey, columnKey);
  4. }

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

  1. @Override
  2. public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
  3. synchronized (mutex) {
  4. return delegate().contains(rowKey, columnKey);
  5. }
  6. }

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

  1. public void testContains() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. assertTrue(table.contains("foo", 1));
  4. assertTrue(table.contains("bar", 1));
  5. assertTrue(table.contains("foo", 3));
  6. assertFalse(table.contains("foo", 2));
  7. assertFalse(table.contains("bar", 3));
  8. assertFalse(table.contains("cat", 1));
  9. assertFalse(table.contains("foo", null));
  10. assertFalse(table.contains(null, 1));
  11. assertFalse(table.contains(null, null));
  12. }

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

  1. @Override
  2. public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
  3. synchronized (mutex) {
  4. return delegate().contains(rowKey, columnKey);
  5. }
  6. }

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

  1. @Override
  2. public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
  3. return original.contains(columnKey, rowKey);
  4. }

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

  1. @Override
  2. public void testContains() {
  3. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  4. assertTrue(table.contains("foo", 1));
  5. assertTrue(table.contains("bar", 1));
  6. assertTrue(table.contains("foo", 3));
  7. assertTrue(table.contains("foo", 2));
  8. assertTrue(table.contains("bar", 3));
  9. assertTrue(table.contains("cat", 1));
  10. assertFalse(table.contains("foo", -1));
  11. assertFalse(table.contains("bad", 1));
  12. assertFalse(table.contains("bad", -1));
  13. assertFalse(table.contains("foo", null));
  14. assertFalse(table.contains(null, 1));
  15. assertFalse(table.contains(null, null));
  16. }

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

  1. @Override
  2. public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
  3. return original.contains(columnKey, rowKey);
  4. }

代码示例来源:origin: SonarSource/sonarqube

  1. @Override
  2. public void store(Measure measure) {
  3. // Emulate duplicate measure check
  4. String componentKey = measure.inputComponent().key();
  5. String metricKey = measure.metric().key();
  6. if (measuresByComponentAndMetric.contains(componentKey, metricKey)) {
  7. throw new IllegalStateException("Can not add the same measure twice");
  8. }
  9. measuresByComponentAndMetric.row(componentKey).put(metricKey, measure);
  10. }

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

  1. @Override
  2. public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
  3. synchronized (mutex) {
  4. return delegate().contains(rowKey, columnKey);
  5. }
  6. }

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

  1. /** Fails if the table contains a mapping for the given row key and column key. */
  2. public void doesNotContain(@NullableDecl Object rowKey, @NullableDecl Object columnKey) {
  3. if (actual().contains(rowKey, columnKey)) {
  4. fail("does not contain mapping for row/column", rowKey, columnKey);
  5. }
  6. }

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

  1. public void testPutNull() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. assertSize(3);
  4. try {
  5. table.put(null, 2, 'd');
  6. fail();
  7. } catch (NullPointerException expected) {
  8. }
  9. try {
  10. table.put("cat", null, 'd');
  11. fail();
  12. } catch (NullPointerException expected) {
  13. }
  14. if (supportsNullValues()) {
  15. assertNull(table.put("cat", 2, null));
  16. assertTrue(table.contains("cat", 2));
  17. } else {
  18. try {
  19. table.put("cat", 2, null);
  20. fail();
  21. } catch (NullPointerException expected) {
  22. }
  23. }
  24. assertSize(3);
  25. }

相关文章