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

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

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

Table.remove介绍

[英]Removes the mapping, if any, associated with the given keys.
[中]删除与给定键关联的映射(如果有)。

代码示例

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

  1. @Override
  2. public V2 remove(Object rowKey, Object columnKey) {
  3. return contains(rowKey, columnKey)
  4. ? function.apply(fromTable.remove(rowKey, columnKey))
  5. : null;
  6. }

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

  1. /**
  2. * @param userId
  3. * @param itemId
  4. * @return
  5. */
  6. public double reomve(int userId, int itemId) {
  7. double previouslyValue = table.remove(userId, itemId);
  8. return previouslyValue;
  9. }

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

  1. /**
  2. * Deletes the given attribute from the given view.
  3. */
  4. public synchronized final void deleteAttribute(String view, String attribute) {
  5. if (attributes != null) {
  6. attributes.remove(view, attribute);
  7. }
  8. }

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

  1. @Override
  2. public V2 remove(Object rowKey, Object columnKey) {
  3. return contains(rowKey, columnKey)
  4. ? function.apply(fromTable.remove(rowKey, columnKey))
  5. : null;
  6. }

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

  1. private static <R, C, V> void merge(
  2. Table<R, C, V> table, R row, C column, V value, BinaryOperator<V> mergeFunction) {
  3. checkNotNull(value);
  4. V oldValue = table.get(row, column);
  5. if (oldValue == null) {
  6. table.put(row, column, value);
  7. } else {
  8. V newValue = mergeFunction.apply(oldValue, value);
  9. if (newValue == null) {
  10. table.remove(row, column);
  11. } else {
  12. table.put(row, column, newValue);
  13. }
  14. }
  15. }

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

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

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

  1. @CanIgnoreReturnValue
  2. @Override
  3. public V remove(Object rowKey, Object columnKey) {
  4. return delegate().remove(rowKey, columnKey);
  5. }

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

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

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

  1. @Override
  2. public V2 remove(Object rowKey, Object columnKey) {
  3. return contains(rowKey, columnKey)
  4. ? function.apply(fromTable.remove(rowKey, columnKey))
  5. : null;
  6. }

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

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

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

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

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

  1. @CanIgnoreReturnValue
  2. @Override
  3. public V remove(Object rowKey, Object columnKey) {
  4. return delegate().remove(rowKey, columnKey);
  5. }

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

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

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

  1. @CanIgnoreReturnValue
  2. @Override
  3. public V remove(Object rowKey, Object columnKey) {
  4. return delegate().remove(rowKey, columnKey);
  5. }

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

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

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

  1. public final void testRemove() {
  2. for (Table<Character, Integer, String> testInstance : getTestInstances()) {
  3. try {
  4. testInstance.remove('a', 1);
  5. fail();
  6. } catch (UnsupportedOperationException e) {
  7. // success
  8. }
  9. }
  10. }

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

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

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

  1. public void testRowClearAndPut() {
  2. if (supportsRemove()) {
  3. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  4. Map<Integer, Character> row = table.row("foo");
  5. assertEquals(ImmutableMap.of(1, 'a', 3, 'c'), row);
  6. table.remove("foo", 3);
  7. assertEquals(ImmutableMap.of(1, 'a'), row);
  8. table.remove("foo", 1);
  9. assertEquals(ImmutableMap.of(), row);
  10. table.put("foo", 2, 'b');
  11. assertEquals(ImmutableMap.of(2, 'b'), row);
  12. row.clear();
  13. assertEquals(ImmutableMap.of(), row);
  14. table.put("foo", 5, 'x');
  15. assertEquals(ImmutableMap.of(5, 'x'), row);
  16. }
  17. }
  18. }

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

  1. public void testSubRowClearAndPut() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. SortedMap<Integer, Character> row = (SortedMap<Integer, Character>) table.row("foo");
  4. SortedMap<Integer, Character> subRow = row.tailMap(2);
  5. assertEquals(ImmutableMap.of(1, 'a', 3, 'c'), row);
  6. assertEquals(ImmutableMap.of(3, 'c'), subRow);
  7. table.remove("foo", 3);
  8. assertEquals(ImmutableMap.of(1, 'a'), row);
  9. assertEquals(ImmutableMap.of(), subRow);
  10. table.remove("foo", 1);
  11. assertEquals(ImmutableMap.of(), row);
  12. assertEquals(ImmutableMap.of(), subRow);
  13. table.put("foo", 2, 'b');
  14. assertEquals(ImmutableMap.of(2, 'b'), row);
  15. assertEquals(ImmutableMap.of(2, 'b'), subRow);
  16. row.clear();
  17. assertEquals(ImmutableMap.of(), row);
  18. assertEquals(ImmutableMap.of(), subRow);
  19. table.put("foo", 5, 'x');
  20. assertEquals(ImmutableMap.of(5, 'x'), row);
  21. assertEquals(ImmutableMap.of(5, 'x'), subRow);
  22. }
  23. }

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

  1. public void testRemove() {
  2. table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c');
  3. if (supportsRemove()) {
  4. assertNull(table.remove("cat", 1));
  5. assertNull(table.remove("bar", 3));
  6. assertEquals(3, table.size());
  7. assertEquals((Character) 'c', table.remove("foo", 3));
  8. assertEquals(2, table.size());
  9. assertEquals((Character) 'a', table.get("foo", 1));
  10. assertEquals((Character) 'b', table.get("bar", 1));
  11. assertNull(table.get("foo", 3));
  12. assertNull(table.remove(null, 1));
  13. assertNull(table.remove("foo", null));
  14. assertNull(table.remove(null, null));
  15. assertSize(2);
  16. } else {
  17. try {
  18. table.remove("foo", 3);
  19. fail();
  20. } catch (UnsupportedOperationException expected) {
  21. }
  22. assertEquals((Character) 'c', table.get("foo", 3));
  23. }
  24. }

相关文章