本文整理了Java中com.google.common.collect.Multimap.values()
方法的一些代码示例,展示了Multimap.values()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multimap.values()
方法的具体详情如下:
包路径:com.google.common.collect.Multimap
类名称:Multimap
方法名:values
[英]Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (so values().size() == size()).
Changes to the returned collection will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.
[中]返回一个视图集合,其中包含此多重映射中包含的每个键值对的值,而不折叠重复项(so values()。size()==size()。
对返回集合的更改将更新基础多重映射,反之亦然。但是,无法添加到返回的集合中。
代码示例来源:origin: google/guava
@Override
public Collection<V> values() {
Collection<V> result = values;
if (result == null) {
values = result = Collections.unmodifiableCollection(delegate.values());
}
return result;
}
代码示例来源:origin: prestodb/presto
/**
* @return constant symbols from a perspective of a subquery
*/
Set<Symbol> getConstantSymbols()
{
return ImmutableSet.copyOf(correlatedSymbolsMapping.values());
}
}
代码示例来源:origin: google/guava
@Override
public Collection<V> values() {
synchronized (mutex) {
if (valuesCollection == null) {
valuesCollection = collection(delegate().values(), mutex);
}
return valuesCollection;
}
}
代码示例来源:origin: google/guava
@Override
public Collection<V> values() {
return delegate().values();
}
代码示例来源:origin: google/guava
public void testValues() {
List<V> expected = Lists.newArrayList();
for (Entry<K, V> entry : getSampleElements()) {
expected.add(entry.getValue());
}
assertEqualIgnoringOrder(expected, multimap().values());
}
代码示例来源:origin: google/guava
@Override
protected void verify(List<Integer> elements) {
assertEquals(elements, Lists.newArrayList(multimap.values()));
}
}.test();
代码示例来源:origin: google/guava
@CollectionFeature.Require(KNOWN_ORDER)
public void testValuesInOrder() {
List<V> expected = Lists.newArrayList();
for (Entry<K, V> entry : getOrderedElements()) {
expected.add(entry.getValue());
}
assertEqualInOrder(expected, multimap().values());
}
代码示例来源:origin: google/guava
@MapFeature.Require(SUPPORTS_REMOVE)
public void testClearThroughValues() {
multimap().values().clear();
assertCleared();
}
代码示例来源: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
@Override
protected Iterator<Integer> newTargetIterator() {
multimap = LinkedHashMultimap.create();
multimap.putAll("foo", asList(2, 3));
multimap.putAll("bar", asList(4, 5));
multimap.putAll("foo", asList(6));
return multimap.values().iterator();
}
代码示例来源:origin: google/guava
public void testLinkedValues() {
Multimap<String, Integer> map = create();
map.put("bar", 1);
map.put("foo", 2);
map.put("bar", 3);
map.put("bar", 4);
assertEquals("[1, 2, 3, 4]", map.values().toString());
map.values().remove(2);
assertEquals("{bar=[1, 3, 4]}", map.toString());
}
代码示例来源:origin: google/guava
public void testIndexIterator() {
final Multimap<String, Object> stringToObject =
new ImmutableMultimap.Builder<String, Object>()
.put("1", 1)
.put("1", 1L)
.put("1", "1")
.put("2", 2)
.put("2", 2L)
.build();
ImmutableMultimap<String, Object> outputMap =
Multimaps.index(stringToObject.values().iterator(), Functions.toStringFunction());
assertEquals(stringToObject, outputMap);
}
代码示例来源:origin: google/guava
public void testIndex() {
final Multimap<String, Object> stringToObject =
new ImmutableMultimap.Builder<String, Object>()
.put("1", 1)
.put("1", 1L)
.put("1", "1")
.put("2", 2)
.put("2", 2L)
.build();
ImmutableMultimap<String, Object> outputMap =
Multimaps.index(stringToObject.values(), Functions.toStringFunction());
assertEquals(stringToObject, outputMap);
}
代码示例来源:origin: google/guava
public void testValuesSpliterator() {
List<Entry<String, Integer>> expectedEntries =
asList(
Maps.immutableEntry("foo", 2),
Maps.immutableEntry("foo", 3),
Maps.immutableEntry("bar", 4),
Maps.immutableEntry("bar", 5),
Maps.immutableEntry("foo", 6));
Multimap<String, Integer> multimap = LinkedHashMultimap.create();
for (Entry<String, Integer> entry : expectedEntries) {
multimap.put(entry.getKey(), entry.getValue());
}
List<Integer> actualValues = new ArrayList<>();
multimap.values().spliterator().forEachRemaining(actualValues::add);
assertThat(actualValues)
.containsExactlyElementsIn(Lists.transform(expectedEntries, Entry::getValue))
.inOrder();
}
}
代码示例来源:origin: google/guava
@Override
public Collection<V> create(Object... elements) {
K k =
((TestMultimapGenerator<K, V, M>) multimapGenerator.getInnerGenerator())
.sampleKeys()
.e0();
Entry<K, V>[] entries = new Entry[elements.length];
for (int i = 0; i < elements.length; i++) {
entries[i] = mapEntry(k, (V) elements[i]);
}
return multimapGenerator.create((Object[]) entries).values();
}
代码示例来源:origin: google/guava
@GwtIncompatible // SerializableTester
public void testSerialization() {
Multimap<String, Integer> multimap = createMultimap();
SerializableTester.reserializeAndAssert(multimap);
assertEquals(multimap.size(), SerializableTester.reserialize(multimap).size());
SerializableTester.reserializeAndAssert(multimap.get("foo"));
LenientSerializableTester.reserializeAndAssertLenient(multimap.keySet());
LenientSerializableTester.reserializeAndAssertLenient(multimap.keys());
SerializableTester.reserializeAndAssert(multimap.asMap());
Collection<Integer> valuesCopy = SerializableTester.reserialize(multimap.values());
assertEquals(HashMultiset.create(multimap.values()), HashMultiset.create(valuesCopy));
}
代码示例来源:origin: google/guava
@GwtIncompatible // SerializableTester
public void testSerialization() {
Multimap<String, Integer> multimap = createMultimap();
SerializableTester.reserializeAndAssert(multimap);
assertEquals(multimap.size(), SerializableTester.reserialize(multimap).size());
SerializableTester.reserializeAndAssert(multimap.get("foo"));
LenientSerializableTester.reserializeAndAssertLenient(multimap.keySet());
LenientSerializableTester.reserializeAndAssertLenient(multimap.keys());
SerializableTester.reserializeAndAssert(multimap.asMap());
Collection<Integer> valuesCopy = SerializableTester.reserialize(multimap.values());
assertEquals(HashMultiset.create(multimap.values()), HashMultiset.create(valuesCopy));
}
代码示例来源:origin: google/guava
private void assertCleared() {
assertEquals(0, multimap().size());
assertEmpty(multimap());
assertEquals(multimap(), getSubjectGenerator().create());
assertEmpty(multimap().entries());
assertEmpty(multimap().asMap());
assertEmpty(multimap().keySet());
assertEmpty(multimap().keys());
assertEmpty(multimap().values());
for (K key : sampleKeys()) {
assertGet(key);
}
}
代码示例来源:origin: google/guava
public void testEmptyMultimapReads() {
Multimap<String, Integer> multimap = ImmutableListMultimap.of();
assertFalse(multimap.containsKey("foo"));
assertFalse(multimap.containsValue(1));
assertFalse(multimap.containsEntry("foo", 1));
assertTrue(multimap.entries().isEmpty());
assertTrue(multimap.equals(ArrayListMultimap.create()));
assertEquals(Collections.emptyList(), multimap.get("foo"));
assertEquals(0, multimap.hashCode());
assertTrue(multimap.isEmpty());
assertEquals(HashMultiset.create(), multimap.keys());
assertEquals(Collections.emptySet(), multimap.keySet());
assertEquals(0, multimap.size());
assertTrue(multimap.values().isEmpty());
assertEquals("{}", multimap.toString());
}
代码示例来源:origin: google/guava
public void testEmptyMultimapReads() {
Multimap<String, Integer> multimap = ImmutableSetMultimap.of();
assertFalse(multimap.containsKey("foo"));
assertFalse(multimap.containsValue(1));
assertFalse(multimap.containsEntry("foo", 1));
assertTrue(multimap.entries().isEmpty());
assertTrue(multimap.equals(HashMultimap.create()));
assertEquals(Collections.emptySet(), multimap.get("foo"));
assertEquals(0, multimap.hashCode());
assertTrue(multimap.isEmpty());
assertEquals(HashMultiset.create(), multimap.keys());
assertEquals(Collections.emptySet(), multimap.keySet());
assertEquals(0, multimap.size());
assertTrue(multimap.values().isEmpty());
assertEquals("{}", multimap.toString());
}
内容来源于网络,如有侵权,请联系作者删除!