本文整理了Java中com.google.common.collect.Multimap.remove()
方法的一些代码示例,展示了Multimap.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.remove()
方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:remove
[英]Removes a single key-value pair with the key key and the value value from this multimap, if such exists. If multiple key-value pairs in the multimap fit this description, which one is removed is unspecified.
[中]从该多重映射(如果存在)中移除具有密钥和值的单个密钥-值对。如果多重映射中的多个键值对符合此描述,则未指定删除哪一个。
代码示例来源:origin: google/guava
@Override
public boolean remove(Object key, Object value) {
synchronized (mutex) {
return delegate().remove(key, value);
}
}
代码示例来源: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: apache/incubator-druid
@Override
public void removeLock(final String taskid, final TaskLock taskLock)
{
giant.lock();
try {
Preconditions.checkNotNull(taskLock, "taskLock");
taskLocks.remove(taskid, taskLock);
}
finally {
giant.unlock();
}
}
代码示例来源:origin: google/guava
@Override
public boolean remove(@Nullable Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) o;
return multimap().remove(entry.getKey(), entry.getValue());
}
return false;
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemovePropagatesToAsMapEntrySet() {
List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries());
for (Entry<K, V> entry : entries) {
resetContainer();
K key = entry.getKey();
V value = entry.getValue();
Iterator<Entry<K, Collection<V>>> asMapItr = multimap().asMap().entrySet().iterator();
Collection<V> collection = null;
while (asMapItr.hasNext()) {
Entry<K, Collection<V>> asMapEntry = asMapItr.next();
if (key.equals(asMapEntry.getKey())) {
collection = asMapEntry.getValue();
break;
}
}
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().remove(key, value);
expectedCollection.remove(value);
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key));
}
}
}
代码示例来源:origin: ctripcorp/apollo
private void removeCache(String key, GrayReleaseRuleCache ruleCache) {
grayReleaseRuleCache.remove(key, ruleCache);
for (GrayReleaseRuleItemDTO ruleItemDTO : ruleCache.getRuleItems()) {
for (String clientIp : ruleItemDTO.getClientIpList()) {
reversedGrayReleaseRuleCache.remove(assembleReversedGrayReleaseRuleKey(ruleItemDTO
.getClientAppId(), ruleCache.getNamespaceName(), clientIp), ruleCache.getRuleId());
}
}
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemovePropagatesToAsMap() {
List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries());
for (Entry<K, V> entry : entries) {
resetContainer();
K key = entry.getKey();
V value = entry.getValue();
Collection<V> collection = multimap().asMap().get(key);
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().remove(key, value);
expectedCollection.remove(value);
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key));
}
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
@Override
public boolean remove(@Nullable Object key, @Nullable Object value) {
return delegate().remove(key, value);
}
代码示例来源:origin: prestodb/presto
public synchronized void finishSplits(int splits)
{
List<Map.Entry<PlanNodeId, Split>> toRemove = new ArrayList<>();
Iterator<Map.Entry<PlanNodeId, Split>> iterator = this.splits.entries().iterator();
while (toRemove.size() < splits && iterator.hasNext()) {
toRemove.add(iterator.next());
}
for (Map.Entry<PlanNodeId, Split> entry : toRemove) {
this.splits.remove(entry.getKey(), entry.getValue());
}
updateSplitQueueSpace();
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemovePropagatesToGet() {
List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries());
for (Entry<K, V> entry : entries) {
resetContainer();
K key = entry.getKey();
V value = entry.getValue();
Collection<V> collection = multimap().get(key);
assertNotNull(collection);
Collection<V> expectedCollection = Helpers.copyToList(collection);
multimap().remove(key, value);
expectedCollection.remove(value);
assertEqualIgnoringOrder(expectedCollection, collection);
assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key));
}
}
代码示例来源:origin: google/guava
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES)
public void testRemoveNullKeyForbidden() {
try {
multimap().remove(null, v0());
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
// success
}
expectUnchanged();
}
代码示例来源:origin: google/guava
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEY_QUERIES})
public void testRemoveNullKeyAbsent() {
assertFalse(multimap().remove(null, v0()));
expectUnchanged();
}
代码示例来源:origin: google/guava
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_VALUE_QUERIES)
public void testRemoveNullValueForbidden() {
try {
multimap().remove(k0(), null);
fail("Expected NullPointerException");
} catch (NullPointerException expected) {
// success
}
expectUnchanged();
}
代码示例来源:origin: google/guava
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUE_QUERIES})
public void testRemoveNullValueAbsent() {
assertFalse(multimap().remove(k0(), null));
expectUnchanged();
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAbsent() {
assertFalse(multimap().remove(k0(), v1()));
expectUnchanged();
}
代码示例来源:origin: google/j2objc
@CanIgnoreReturnValue
@Override
public boolean remove(@NullableDecl Object key, @NullableDecl Object value) {
return delegate().remove(key, value);
}
代码示例来源:origin: google/guava
@GwtIncompatible // SeriazableTester
public void testSerializationOrderingKeysAndEntries() {
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
multimap.put("a", 1);
multimap.put("b", 2);
multimap.put("a", 3);
multimap.put("c", 4);
multimap.remove("a", 1);
multimap = SerializableTester.reserializeAndAssert(multimap);
assertThat(multimap.keySet()).containsExactly("a", "b", "c").inOrder();
assertThat(multimap.entries())
.containsExactly(mapEntry("b", 2), mapEntry("a", 3), mapEntry("c", 4))
.inOrder();
// note that the keys and entries are in different orders
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_KEYS})
public void testRemoveNullKeyPresent() {
initMultimapWithNullKey();
assertTrue(multimap().remove(null, getValueForNullKey()));
expectMissing(Helpers.mapEntry((K) null, getValueForNullKey()));
assertGet(getKeyForNullValue(), ImmutableList.<V>of());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({SUPPORTS_REMOVE, ALLOWS_NULL_VALUES})
public void testRemoveNullValuePresent() {
initMultimapWithNullValue();
assertTrue(multimap().remove(getKeyForNullValue(), null));
expectMissing(Helpers.mapEntry(getKeyForNullValue(), (V) null));
assertGet(getKeyForNullValue(), ImmutableList.<V>of());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(SUPPORTS_REMOVE)
public void testRemovePresent() {
assertTrue(multimap().remove(k0(), v0()));
assertFalse(multimap().containsEntry(k0(), v0()));
expectMissing(e0());
assertEquals(getNumElements() - 1, multimap().size());
assertGet(k0(), ImmutableList.<V>of());
}
内容来源于网络,如有侵权,请联系作者删除!