本文整理了Java中com.google.common.collect.Multiset.retainAll()
方法的一些代码示例,展示了Multiset.retainAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multiset.retainAll()
方法的具体详情如下:
包路径:com.google.common.collect.Multiset
类名称:Multiset
方法名:retainAll
[英]Note: This method ignores how often any element might appear in c, and only cares whether or not an element appears at all. If you wish to remove one occurrence in this multiset for every occurrence in c, see Multisets#retainOccurrences(Multiset,Multiset).
This method refines Collection#retainAll to further specify that it may not throw an exception in response to any of elementsbeing null or of the wrong type.
[中]注意:此方法忽略任何元素在c中出现的频率,只关心元素是否出现。如果希望为c中的每个事件删除此multiset中的一个事件,请参见multiset#retainOccurrences(multiset,multiset)。
此方法细化了集合#retainal,以进一步指定它不会在响应任何元素为null或类型错误时引发异常。
代码示例来源:origin: google/guava
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRetainAllIgnoresCount() {
initThreeCopies();
List<E> contents = Helpers.copyToList(getMultiset());
assertFalse(getMultiset().retainAll(Collections.singleton(e0())));
expectContents(contents);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public boolean retainAll(Collection<?> arg0) {
return multiset.retainAll(arg0);
}
代码示例来源:origin: com.google.guava/guava-testlib-jdk5
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRetainAllIgnoresCount() {
initThreeCopies();
List<E> contents = Helpers.copyToList(getMultiset());
assertFalse(getMultiset().retainAll(Collections.singleton(samples.e0)));
expectContents(contents);
}
代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.xbase
/**
* Keeps the cumulated distance for all the common raw super types of the given references.
* Interfaces that are more directly implemented will get a lower total count than more general
* interfaces.
*/
protected void cumulateDistance(final List<LightweightTypeReference> references, Multimap<JvmType, LightweightTypeReference> all,
Multiset<JvmType> cumulatedDistance) {
for(LightweightTypeReference other: references) {
Multiset<JvmType> otherDistance = LinkedHashMultiset.create();
initializeDistance(other, all, otherDistance);
cumulatedDistance.retainAll(otherDistance);
for(Multiset.Entry<JvmType> typeToDistance: otherDistance.entrySet()) {
if (cumulatedDistance.contains(typeToDistance.getElement()))
cumulatedDistance.add(typeToDistance.getElement(), typeToDistance.getCount());
}
}
}
代码示例来源:origin: org.eclipse.xtext.common/types
/**
* Keeps the cumulated distance for all the common raw super types of the given references.
* Interfaces that are more directly implemented will get a lower total count than more general
* interfaces.
*/
protected void cumulateDistance(final List<JvmTypeReference> references, Multimap<JvmType, JvmTypeReference> all,
Multiset<JvmType> cumulatedDistance) {
for(JvmTypeReference other: references) {
Multiset<JvmType> otherDistance = LinkedHashMultiset.create();
initializeDistance(other, all, otherDistance);
cumulatedDistance.retainAll(otherDistance);
for(Multiset.Entry<JvmType> typeToDistance: otherDistance.entrySet()) {
if (cumulatedDistance.contains(typeToDistance.getElement()))
cumulatedDistance.add(typeToDistance.getElement(), typeToDistance.getCount());
}
}
}
代码示例来源:origin: com.google.guava/guava-testlib
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRetainAllIgnoresCount() {
initThreeCopies();
List<E> contents = Helpers.copyToList(getMultiset());
assertFalse(getMultiset().retainAll(Collections.singleton(e0())));
expectContents(contents);
}
内容来源于网络,如有侵权,请联系作者删除!