本文整理了Java中com.google.common.collect.Multimap.removeAll()
方法的一些代码示例,展示了Multimap.removeAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.removeAll()
方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:removeAll
[英]Removes all values associated with the key key.
Once this method returns, key will not be mapped to any values, so it will not appear in #keySet(), #asMap(), or any other views.
[中]删除与该键关联的所有值。
此方法返回后,键将不会映射到任何值,因此它不会出现在#keySet()、#asMap()或任何其他视图中。
代码示例来源:origin: google/guava
@SuppressWarnings("unchecked")
@Override
public List<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
代码示例来源:origin: google/guava
@SuppressWarnings("unchecked")
@Override
public Collection<V2> removeAll(Object key) {
return transform((K) key, fromMultimap.removeAll(key));
}
代码示例来源:origin: google/guava
@Override
public Collection<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
}
代码示例来源:origin: google/guava
@Override
public Collection<V> remove(Object key) {
return containsKey(key) ? multimap.removeAll(key) : null;
}
代码示例来源:origin: google/j2objc
@Override
public Collection<V> removeAll(Object key) {
synchronized (mutex) {
return delegate().removeAll(key); // copy not synchronized
}
}
代码示例来源:origin: google/guava
@Override
public Collection<V> removeAll(Object key) {
return containsKey(key) ? unfiltered.removeAll(key) : unmodifiableEmptyCollection();
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testEntriesRemainValidAfterRemove() {
Iterator<Entry<K, V>> iterator = multimap().entries().iterator();
Entry<K, V> entry = iterator.next();
K key = entry.getKey();
V value = entry.getValue();
multimap().removeAll(key);
assertEquals(key, entry.getKey());
assertEquals(value, entry.getValue());
}
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
@Override
public Collection<V> removeAll(@Nullable Object key) {
return delegate().removeAll(key);
}
代码示例来源:origin: google/guava
/** Confirm that removeAll() returns a List implementing RandomAccess. */
public void testRemoveAllRandomAccess() {
Multimap<String, Integer> multimap = create();
multimap.put("foo", 1);
multimap.put("foo", 3);
assertTrue(multimap.removeAll("foo") instanceof RandomAccess);
assertTrue(multimap.removeAll("bar") instanceof RandomAccess);
}
代码示例来源:origin: google/guava
/**
* Confirm that removeAll() returns a List that implements RandomAccess, even though get()
* doesn't.
*/
public void testRemoveAllRandomAccess() {
Multimap<String, Integer> multimap = create();
multimap.put("foo", 1);
multimap.put("foo", 3);
assertTrue(multimap.removeAll("foo") instanceof RandomAccess);
assertTrue(multimap.removeAll("bar") instanceof RandomAccess);
}
代码示例来源:origin: google/guava
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_ANY_NULL_QUERIES})
public void testRemoveAllNullKeyAbsent() {
assertEmpty(multimap().removeAll(null));
expectUnchanged();
}
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testReflectsMultimapRemove() {
Collection<V> result = multimap().asMap().get(k0());
multimap().removeAll(k0());
assertEmpty(result);
}
}
代码示例来源:origin: google/j2objc
@CanIgnoreReturnValue
@Override
public Collection<V> removeAll(@NullableDecl Object key) {
return delegate().removeAll(key);
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllAbsentKey() {
assertEmpty(multimap().removeAll(k3()));
expectUnchanged();
}
代码示例来源:origin: google/guava
public void testForMapRemoveAll() {
Map<String, Integer> map = Maps.newHashMap();
map.put("foo", 1);
map.put("bar", 2);
map.put("cow", 3);
Multimap<String, Integer> multimap = Multimaps.forMap(map);
assertEquals(3, multimap.size());
assertEquals(Collections.emptySet(), multimap.removeAll("dog"));
assertEquals(3, multimap.size());
assertTrue(multimap.containsKey("bar"));
assertEquals(Collections.singleton(2), multimap.removeAll("bar"));
assertEquals(2, multimap.size());
assertFalse(multimap.containsKey("bar"));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllPropagatesToGet() {
Collection<V> getResult = multimap().get(k0());
multimap().removeAll(k0());
assertEmpty(getResult);
expectMissing(e0());
}
代码示例来源:origin: google/guava
public void testOrderingUpdates() {
Multimap<String, Integer> multimap = initializeMultimap5();
assertThat(multimap.replaceValues("foo", asList(6, 7))).containsExactly(5, 3).inOrder();
assertThat(multimap.keySet()).containsExactly("foo", "bar", "cow").inOrder();
assertThat(multimap.removeAll("foo")).containsExactly(6, 7).inOrder();
assertThat(multimap.keySet()).containsExactly("bar", "cow").inOrder();
assertTrue(multimap.remove("bar", 4));
assertThat(multimap.keySet()).containsExactly("bar", "cow").inOrder();
assertTrue(multimap.remove("bar", 1));
assertThat(multimap.keySet()).contains("cow");
multimap.put("bar", 9);
assertThat(multimap.keySet()).containsExactly("cow", "bar").inOrder();
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllPresentKey() {
assertContentsAnyOrder(multimap().removeAll(k0()), v0());
expectMissing(e0());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
public void testRemoveAllNullKeyPresent() {
initMultimapWithNullKey();
assertContentsAnyOrder(multimap().removeAll(null), getValueForNullKey());
expectMissing(Helpers.mapEntry((K) null, getValueForNullKey()));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllMultipleValues() {
resetContainer(
Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v1()), Helpers.mapEntry(k0(), v2()));
assertContentsAnyOrder(multimap().removeAll(k0()), v0(), v1(), v2());
assertEmpty(multimap());
}
内容来源于网络,如有侵权,请联系作者删除!