本文整理了Java中com.google.common.collect.Multimap.isEmpty()
方法的一些代码示例,展示了Multimap.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.isEmpty()
方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:isEmpty
[英]Returns true if this multimap contains no key-value pairs. Equivalent to size(), but can in some cases be more efficient.
[中]如果此多重映射不包含键值对,则返回true。相当于size(),但在某些情况下效率更高。
代码示例来源:origin: google/guava
@Override
public boolean isEmpty() {
return fromMultimap.isEmpty();
}
代码示例来源:origin: google/guava
@Override
public boolean isEmpty() {
return multimap.isEmpty();
}
代码示例来源:origin: google/guava
static void assertEmpty(Multimap<?, ?> multimap) {
if (!multimap.isEmpty()) {
fail("Not true that " + multimap + " is empty");
}
}
}
代码示例来源:origin: google/guava
@Override
public boolean isEmpty() {
synchronized (mutex) {
return delegate().isEmpty();
}
}
代码示例来源:origin: google/guava
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
代码示例来源:origin: google/guava
private static <K, V> ImmutableSetMultimap<K, V> copyOf(
Multimap<? extends K, ? extends V> multimap, Comparator<? super V> valueComparator) {
checkNotNull(multimap); // eager for GWT
if (multimap.isEmpty() && valueComparator == null) {
return of();
}
if (multimap instanceof ImmutableSetMultimap) {
@SuppressWarnings("unchecked") // safe since multimap is not writable
ImmutableSetMultimap<K, V> kvMultimap = (ImmutableSetMultimap<K, V>) multimap;
if (!kvMultimap.isPartialView()) {
return kvMultimap;
}
}
return fromMapEntries(multimap.asMap().entrySet(), valueComparator);
}
代码示例来源:origin: google/guava
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
@CollectionSize.Require(ONE)
public void testValuesIteratorRemove() {
Iterator<V> valuesItr = multimap().values().iterator();
valuesItr.next();
valuesItr.remove();
assertTrue(multimap().isEmpty());
}
}
代码示例来源:origin: google/guava
@CollectionSize.Require(ZERO)
public void testIsEmptyYes() {
assertTrue(multimap().isEmpty());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
public void testIsEmptyNo() {
assertFalse(multimap().isEmpty());
}
代码示例来源:origin: google/guava
protected void assertGet(K key, Collection<V> values) {
assertEqualIgnoringOrder(values, multimap().get(key));
if (!values.isEmpty()) {
assertEqualIgnoringOrder(values, multimap().asMap().get(key));
assertFalse(multimap().isEmpty());
} else {
assertNull(multimap().asMap().get(key));
}
assertEquals(values.size(), multimap().get(key).size());
assertEquals(values.size() > 0, multimap().containsKey(key));
assertEquals(values.size() > 0, multimap().keySet().contains(key));
assertEquals(values.size() > 0, multimap().keys().contains(key));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testIteratorRemovePropagatesToMultimap() {
Iterator<Entry<K, V>> iterator = multimap().entries().iterator();
assertEquals(Helpers.mapEntry(k0(), v0()), iterator.next());
iterator.remove();
assertTrue(multimap().isEmpty());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testAsMapEntrySetIteratorRemovePropagatesToMultimap() {
resetContainer(Helpers.mapEntry(k0(), v0()), Helpers.mapEntry(k0(), v3()));
Set<Entry<K, Collection<V>>> asMapEntrySet = multimap().asMap().entrySet();
Iterator<Entry<K, Collection<V>>> asMapEntryItr = asMapEntrySet.iterator();
asMapEntryItr.next();
asMapEntryItr.remove();
assertTrue(multimap().isEmpty());
}
}
代码示例来源:origin: google/guava
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testKeysEntrySetIteratorRemove() {
Multiset<K> keys = multimap().keys();
Iterator<Multiset.Entry<K>> itr = keys.entrySet().iterator();
assertEquals(Multisets.immutableEntry(k0(), 1), itr.next());
itr.remove();
assertTrue(multimap().isEmpty());
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_PUT)
public void testPutAllIntoEmpty() {
Multimap<K, V> target = getSubjectGenerator().create();
assertEquals(!multimap().isEmpty(), target.putAll(multimap()));
assertEquals(multimap(), target);
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testSizeNullValue() {
initMultimapWithNullValue();
assertEquals(getNumElements(), multimap().size());
assertFalse(multimap().isEmpty());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testSizeNullKey() {
initMultimapWithNullKey();
assertEquals(getNumElements(), multimap().size());
assertFalse(multimap().isEmpty());
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@MapFeature.Require({ALLOWS_NULL_KEYS, ALLOWS_NULL_VALUES})
public void testSizeNullKeyAndValue() {
initMultimapWithNullKeyAndValue();
assertEquals(getNumElements(), multimap().size());
assertFalse(multimap().isEmpty());
}
代码示例来源:origin: google/guava
public void testInvertFrom() {
ImmutableMultimap<Integer, String> empty = ImmutableMultimap.of();
// typical usage example - sad that ArrayListMultimap.create() won't work
Multimap<String, Integer> multimap =
Multimaps.invertFrom(empty, ArrayListMultimap.<String, Integer>create());
assertTrue(multimap.isEmpty());
ImmutableMultimap<Integer, String> single =
new ImmutableMultimap.Builder<Integer, String>().put(1, "one").put(2, "two").build();
// copy into existing multimap
assertSame(multimap, Multimaps.invertFrom(single, multimap));
ImmutableMultimap<String, Integer> expected =
new ImmutableMultimap.Builder<String, Integer>().put("one", 1).put("two", 2).build();
assertEquals(expected, multimap);
}
代码示例来源:origin: google/guava
public void testMultimapReads() {
Multimap<String, Integer> multimap = createMultimap();
assertTrue(multimap.containsKey("foo"));
assertFalse(multimap.containsKey("cat"));
assertTrue(multimap.containsValue(1));
assertFalse(multimap.containsValue(5));
assertTrue(multimap.containsEntry("foo", 1));
assertFalse(multimap.containsEntry("cat", 1));
assertFalse(multimap.containsEntry("foo", 5));
assertFalse(multimap.entries().isEmpty());
assertEquals(3, multimap.size());
assertFalse(multimap.isEmpty());
assertEquals("{foo=[1, 3], bar=[2]}", multimap.toString());
}
代码示例来源:origin: google/guava
public void testMultimapReads() {
Multimap<String, Integer> multimap = createMultimap();
assertTrue(multimap.containsKey("foo"));
assertFalse(multimap.containsKey("cat"));
assertTrue(multimap.containsValue(1));
assertFalse(multimap.containsValue(5));
assertTrue(multimap.containsEntry("foo", 1));
assertFalse(multimap.containsEntry("cat", 1));
assertFalse(multimap.containsEntry("foo", 5));
assertFalse(multimap.entries().isEmpty());
assertEquals(3, multimap.size());
assertFalse(multimap.isEmpty());
assertEquals("{foo=[1, 3], bar=[2]}", multimap.toString());
}
内容来源于网络,如有侵权,请联系作者删除!