Top Inners Constructors Methods
org.eclipse.collections.impl.multimap

public abstract Class AbstractMultimap<K, V, C extends RichIterable<V>>

extends Object
implements Multimap<K, V>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.multimap.Multimap
Known Direct Subclasses
org.eclipse.collections.impl.multimap.AbstractMutableMultimap, org.eclipse.collections.impl.multimap.AbstractImmutableMultimap
Imports
java.util.Map, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.Bag, .MutableBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.predicate.Predicate2, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.factory.Bags, org.eclipse.collections.api.map.MapIterable, org.eclipse.collections.api.multimap.Multimap, .MutableMultimap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.UnmodifiableRichIterable, org.eclipse.collections.impl.block.factory.Functions, org.eclipse.collections.impl.tuple.Tuples

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <K2, V2, R extends MutableMultimap<K2, V2>> R
collectKeyMultiValues(Function<? super K, ? extends K2> keyFunction, Function<? super V, ? extends V2> valueFunction, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectKeyMultiValues.

Same as the collectKeyMultiValues method but uses the specified target multimap for the results.

public <K2, V2, R extends MutableMultimap<K2, V2>> R
collectKeysValues(Function2<? super K, ? super V, Pair<K2, V2>> function, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectKeysValues.

Same as the collect method but uses the specified target multimap for the results.

public <V2, R extends MutableMultimap<K, V2>> R
collectValues(Function<? super V, ? extends V2> function, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectValues.

Same as the collect method but uses the specified target multimap for the results.

public boolean
containsKey(Object key)

Implements org.eclipse.collections.api.multimap.Multimap.containsKey.

Returns true if any values are mapped to the specified key.

public boolean
containsKeyAndValue(Object key, Object value)

Implements org.eclipse.collections.api.multimap.Multimap.containsKeyAndValue.

Returns true if the specified key-value pair is mapped.

public boolean
containsValue(Object value)

Implements org.eclipse.collections.api.multimap.Multimap.containsValue.

Returns true if any key is mapped to the specified value.

protected abstract C

Returns:

an empty collection of values
createCollection
()

Creates the collection of values for a single key.

protected Function<AbstractMultimap<K, V, C>, C>
public boolean
equals(Object object)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.multimap.Multimap.equals.

Compares the specified object with this Multimap for equality.

public void
forEachKey(Procedure<? super K> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKey.

Calls the procedure with each key.

public void
forEachKeyMultiValues(Procedure2<? super K, ? super RichIterable<V>> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKeyMultiValues.

Calls the procedure with each key-Iterable[value].

public void
forEachKeyValue(Procedure2<? super K, ? super V> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKeyValue.

Calls the procedure with each key-value pair.

public void
forEachValue(Procedure<? super V> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachValue.

Calls the procedure with each value.

protected abstract MapIterable<K, C>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.eclipse.collections.api.multimap.Multimap.hashCode.

Returns the hash code for this multimap.

public Bag<K>
keyBag()

Implements org.eclipse.collections.api.multimap.Multimap.keyBag.

Returns a Bag of keys with the count corresponding to the number of mapped values.

public RichIterable<Pair<K, RichIterable<V>>>
keyMultiValuePairsView()

Implements org.eclipse.collections.api.multimap.Multimap.keyMultiValuePairsView.

Returns a lazy view of the pair of a key and a lazy view of the values mapped to that key.

public RichIterable<K>
keysView()

Implements org.eclipse.collections.api.multimap.Multimap.keysView.

Returns a lazy view of the unique keys.

public RichIterable<Pair<K, V>>
keyValuePairsView()

Implements org.eclipse.collections.api.multimap.Multimap.keyValuePairsView.

Returns a lazy view of all the key/value pairs.

public RichIterable<RichIterable<V>>
multiValuesView()

Implements org.eclipse.collections.api.multimap.Multimap.multiValuesView.

Returns an unmodifiable view of all the values mapped to each key.

public boolean
notEmpty()

Implements org.eclipse.collections.api.multimap.Multimap.notEmpty.

Returns true if there is at least one entry.

public <R extends MutableMultimap<K, V>> R
rejectKeysMultiValues(Predicate2<? super K, ? super RichIterable<V>> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.rejectKeysMultiValues.

Same as the reject method but uses the specified target multimap for the results.

public <R extends MutableMultimap<K, V>> R
rejectKeysValues(Predicate2<? super K, ? super V> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.rejectKeysValues.

Same as the reject method but uses the specified target multimap for the results.

public <R extends MutableMultimap<K, V>> R
selectKeysMultiValues(Predicate2<? super K, ? super RichIterable<V>> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.selectKeysMultiValues.

Same as the select method but uses the specified target multimap for the results.

public <R extends MutableMultimap<K, V>> R
selectKeysValues(Predicate2<? super K, ? super V> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.selectKeysValues.

Same as the select method but uses the specified target multimap for the results.

public String

Returns:

a string representation of the multimap
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the multimap, generated by calling toString on the map returned by Multimap#toMap().

public RichIterable<V>
valuesView()

Implements org.eclipse.collections.api.multimap.Multimap.valuesView.

Returns a lazy flattened view of all the values.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Constructor Detail

AbstractMultimapback to summary
public AbstractMultimap()

Method Detail

collectKeyMultiValuesback to summary
public <K2, V2, R extends MutableMultimap<K2, V2>> R collectKeyMultiValues(Function<? super K, ? extends K2> keyFunction, Function<? super V, ? extends V2> valueFunction, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectKeyMultiValues.

Doc from org.eclipse.collections.api.multimap.Multimap.collectKeyMultiValues.

Same as the collectKeyMultiValues method but uses the specified target multimap for the results.

e.g.
return multimap.collectKeyMultiValues(each -> each + 1, Person::getLastName, HashBagMultimap.<Integer, String>newMultimap());
Annotations
@Override
collectKeysValuesback to summary
public <K2, V2, R extends MutableMultimap<K2, V2>> R collectKeysValues(Function2<? super K, ? super V, Pair<K2, V2>> function, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectKeysValues.

Doc from org.eclipse.collections.api.multimap.Multimap.collectKeysValues.

Same as the collect method but uses the specified target multimap for the results.

e.g.
return multimap.collectKeysValues(new Function2<Integer, Person, Pair<String, String>>()
{
    public Pair<String, String> valueOf(Integer age, Person person)
    {
        return Tuples.pair(age.toString(), person.getLastName());
    }
}, HashBagMultimap.<String, String>newMultimap());
Annotations
@Override
collectValuesback to summary
public <V2, R extends MutableMultimap<K, V2>> R collectValues(Function<? super V, ? extends V2> function, R target)

Implements org.eclipse.collections.api.multimap.Multimap.collectValues.

Doc from org.eclipse.collections.api.multimap.Multimap.collectValues.

Same as the collect method but uses the specified target multimap for the results.

e.g.
return multimap.collectValues(new Function<Person, String>()
{
    public String valueOf(Person person)
    {
        return person.getLastName();
    }
}, FastListMultimap.<Integer, String>newMultimap());
Annotations
@Override
containsKeyback to summary
public boolean containsKey(Object key)

Implements org.eclipse.collections.api.multimap.Multimap.containsKey.

Doc from org.eclipse.collections.api.multimap.Multimap.containsKey.

Returns true if any values are mapped to the specified key.

Annotations
@Override
containsKeyAndValueback to summary
public boolean containsKeyAndValue(Object key, Object value)

Implements org.eclipse.collections.api.multimap.Multimap.containsKeyAndValue.

Doc from org.eclipse.collections.api.multimap.Multimap.containsKeyAndValue.

Returns true if the specified key-value pair is mapped.

Annotations
@Override
containsValueback to summary
public boolean containsValue(Object value)

Implements org.eclipse.collections.api.multimap.Multimap.containsValue.

Doc from org.eclipse.collections.api.multimap.Multimap.containsValue.

Returns true if any key is mapped to the specified value.

Annotations
@Override
createCollectionback to summary
protected abstract C createCollection()

Creates the collection of values for a single key.

Collections with weak, soft, or phantom references are not supported. Each call to createCollection should create a new instance.

The returned collection class determines whether duplicate key-value pairs are allowed.

Returns:C

an empty collection of values

createCollectionBlockback to summary
protected Function<AbstractMultimap<K, V, C>, C> createCollectionBlock()
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.multimap.Multimap.equals.

Doc from org.eclipse.collections.api.multimap.Multimap.equals.

Compares the specified object with this Multimap for equality.

Two Multimaps are equal when their map views (as returned by toMap) are also equal.

In general, two Multimaps with identical key-value mappings may or may not be equal, depending on the type of the collections holding the values. If the backing collections are Sets, then two instances with the same key-value mappings are equal, but if the backing collections are Lists, equality depends on the ordering of the values for each key.

Any two empty Multimaps are equal, because they both have empty toMap views.

Annotations
@Override
forEachKeyback to summary
public void forEachKey(Procedure<? super K> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKey.

Doc from org.eclipse.collections.api.multimap.Multimap.forEachKey.

Calls the procedure with each key.

Given a Multimap with the contents:

{"key1" : ["val1", "val2", "val2"], "key2" : ["val3"]}

The given procedure would be invoked with the parameters:

["key1", "key2"]

Annotations
@Override
forEachKeyMultiValuesback to summary
public void forEachKeyMultiValues(Procedure2<? super K, ? super RichIterable<V>> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKeyMultiValues.

Doc from org.eclipse.collections.api.multimap.Multimap.forEachKeyMultiValues.

Calls the procedure with each key-Iterable[value].

Given a Multimap with the contents:

{"key1" : ["val1", "val2", "val2"], "key2" : ["val3"]}

The given procedure would be invoked with the parameters:

[["key1", {@link RichIterable["val1", "val2", "val2"]}], ["key2", {@link RichIterable["val3"]}]]

Annotations
@Override
forEachKeyValueback to summary
public void forEachKeyValue(Procedure2<? super K, ? super V> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachKeyValue.

Doc from org.eclipse.collections.api.multimap.Multimap.forEachKeyValue.

Calls the procedure with each key-value pair.

Given a Multimap with the contents:

{"key1" : ["val1", "val2", "val2"], "key2" : ["val3"]}

The given procedure would be invoked with the parameters:

[["key1", "val1"], ["key1", "val2"], ["key1", "val2"], ["key2", "val3"]]

Annotations
@Override
forEachValueback to summary
public void forEachValue(Procedure<? super V> procedure)

Implements org.eclipse.collections.api.multimap.Multimap.forEachValue.

Doc from org.eclipse.collections.api.multimap.Multimap.forEachValue.

Calls the procedure with each value.

Given a Multimap with the contents:

{"key1" : ["val1", "val2", "val2"], "key2" : ["val3"]}

The given procedure would be invoked with the parameters:

["val1", "val2", "val2", "val3"]

Annotations
@Override
getMapback to summary
protected abstract MapIterable<K, C> getMap()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.eclipse.collections.api.multimap.Multimap.hashCode.

Returns the hash code for this multimap.

The hash code of a multimap is defined as the hash code of the map view, as returned by Multimap#toMap().

Annotations
@Override
See Also
Map#hashCode()
keyBagback to summary
public Bag<K> keyBag()

Implements org.eclipse.collections.api.multimap.Multimap.keyBag.

Doc from org.eclipse.collections.api.multimap.Multimap.keyBag.

Returns a Bag of keys with the count corresponding to the number of mapped values.

Annotations
@Override
keyMultiValuePairsViewback to summary
public RichIterable<Pair<K, RichIterable<V>>> keyMultiValuePairsView()

Implements org.eclipse.collections.api.multimap.Multimap.keyMultiValuePairsView.

Doc from org.eclipse.collections.api.multimap.Multimap.keyMultiValuePairsView.

Returns a lazy view of the pair of a key and a lazy view of the values mapped to that key.

Annotations
@Override
keysViewback to summary
public RichIterable<K> keysView()

Implements org.eclipse.collections.api.multimap.Multimap.keysView.

Doc from org.eclipse.collections.api.multimap.Multimap.keysView.

Returns a lazy view of the unique keys.

Annotations
@Override
keyValuePairsViewback to summary
public RichIterable<Pair<K, V>> keyValuePairsView()

Implements org.eclipse.collections.api.multimap.Multimap.keyValuePairsView.

Doc from org.eclipse.collections.api.multimap.Multimap.keyValuePairsView.

Returns a lazy view of all the key/value pairs.

Annotations
@Override
multiValuesViewback to summary
public RichIterable<RichIterable<V>> multiValuesView()

Implements org.eclipse.collections.api.multimap.Multimap.multiValuesView.

Doc from org.eclipse.collections.api.multimap.Multimap.multiValuesView.

Returns an unmodifiable view of all the values mapped to each key.

Annotations
@Override
notEmptyback to summary
public boolean notEmpty()

Implements org.eclipse.collections.api.multimap.Multimap.notEmpty.

Doc from org.eclipse.collections.api.multimap.Multimap.notEmpty.

Returns true if there is at least one entry.

Annotations
@Override
rejectKeysMultiValuesback to summary
public <R extends MutableMultimap<K, V>> R rejectKeysMultiValues(Predicate2<? super K, ? super RichIterable<V>> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.rejectKeysMultiValues.

Doc from org.eclipse.collections.api.multimap.Multimap.rejectKeysMultiValues.

Same as the reject method but uses the specified target multimap for the results.

e.g.
return multimap.rejectKeysMultiValues(new Predicate2<Integer, Iterable<Person>>()
{
    public boolean accept(Integer age, Iterable<Person> values)
    {
        return (age >= 18)
                 && ((RichIterable<Person>)values.size() >= 2);
    }
}, FastListMultimap.newMultimap());
Annotations
@Override
rejectKeysValuesback to summary
public <R extends MutableMultimap<K, V>> R rejectKeysValues(Predicate2<? super K, ? super V> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.rejectKeysValues.

Doc from org.eclipse.collections.api.multimap.Multimap.rejectKeysValues.

Same as the reject method but uses the specified target multimap for the results.

e.g.
return multimap.rejectKeysValues(new Predicate2<Integer, Person>()
{
    public boolean accept(Integer age, Person person)
    {
        return (age >= 18)
                 && (person.getAddress().getCity().equals("Metuchen"));
    }
}, FastListMultimap.newMultimap());
Annotations
@Override
selectKeysMultiValuesback to summary
public <R extends MutableMultimap<K, V>> R selectKeysMultiValues(Predicate2<? super K, ? super RichIterable<V>> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.selectKeysMultiValues.

Doc from org.eclipse.collections.api.multimap.Multimap.selectKeysMultiValues.

Same as the select method but uses the specified target multimap for the results.

e.g.
return multimap.selectKeysMultiValues(new Predicate2<Integer, Iterable<Person>>()
{
    public boolean accept(Integer age, Iterable<Person> values)
    {
        return (age >= 18)
                 && ((RichIterable<Person>)values.size() >= 2);
    }
}, FastListMultimap.newMultimap());
Annotations
@Override
selectKeysValuesback to summary
public <R extends MutableMultimap<K, V>> R selectKeysValues(Predicate2<? super K, ? super V> predicate, R target)

Implements org.eclipse.collections.api.multimap.Multimap.selectKeysValues.

Doc from org.eclipse.collections.api.multimap.Multimap.selectKeysValues.

Same as the select method but uses the specified target multimap for the results.

e.g.
return multimap.selectKeysValues(new Predicate2<Integer, Person>()
{
    public boolean accept(Integer age, Person person)
    {
        return (age >= 18)
                 && (person.getAddress().getCity().equals("Metuchen"));
    }
}, FastListMultimap.newMultimap());
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the multimap, generated by calling toString on the map returned by Multimap#toMap().

Returns:String

a string representation of the multimap

Annotations
@Override
valuesViewback to summary
public RichIterable<V> valuesView()

Implements org.eclipse.collections.api.multimap.Multimap.valuesView.

Doc from org.eclipse.collections.api.multimap.Multimap.valuesView.

Returns a lazy flattened view of all the values.

Annotations
@Override
org.eclipse.collections.impl.multimap back to summary

private final Class AbstractMultimap.KeyValuePairFunction<V, K>

extends Object
implements Function<V, Pair<K, V>>
Class Inheritance
  • java.lang.Object
  • org.eclipse.collections.impl.multimap.AbstractMultimap.KeyValuePairFunction
All Implemented Interfaces
org.eclipse.collections.api.block.function.Function, java.io.Serializable, java.util.function.Function

Field Summary

Modifier and TypeField and Description
private final K
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Pair<K, V>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final K key
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

KeyValuePairFunctionback to summary
private KeyValuePairFunction(K key)

Method Detail

valueOfback to summary
public Pair<K, V> valueOf(V value)

Implements org.eclipse.collections.api.block.function.Function.valueOf.

Annotations
@Override