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

public abstract Class AbstractSynchronizedMultimap<K, V>

extends Object
implements MutableMultimap<K, V>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.multimap.MutableMultimap, org.eclipse.collections.api.multimap.Multimap
Known Direct Subclasses
org.eclipse.collections.impl.multimap.bag.SynchronizedBagMultimap, org.eclipse.collections.impl.multimap.bag.sorted.mutable.SynchronizedSortedBagMultimap, org.eclipse.collections.impl.multimap.list.SynchronizedListMultimap, org.eclipse.collections.impl.multimap.set.SynchronizedSetMultimap, org.eclipse.collections.impl.multimap.set.sorted.SynchronizedSortedSetMultimap
Imports
java.util.Collection, .Set, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.Bag, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, org.eclipse.collections.api.block.predicate.Predicate2, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.multimap.Multimap, .MutableMultimap, org.eclipse.collections.api.set.SetIterable, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.bag.mutable.SynchronizedBag, org.eclipse.collections.impl.map.mutable.SynchronizedMutableMap, org.eclipse.collections.impl.set.mutable.SynchronizedMutableSet, org.eclipse.collections.impl.utility.LazyIterate

Field Summary

Modifier and TypeField and Description
protected final MutableMultimap<K, V>
private final Object

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
public boolean
add(Pair<? extends K, ? extends V> keyValuePair)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.add.

Modification operation similar to put, however, takes the key-value pair as the input.

public void
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.

public boolean
equals(Object obj)

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 MutableMultimap<K, V>
protected Object
public int
hashCode()

Overrides java.lang.Object.hashCode.

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

Returns the hash code for this Multimap.

public boolean
isEmpty()

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

Returns true if there are no entries.

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 SetIterable<K>
keySet()

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

Returns an unmodifiable SetIterable of keys with O(1) complexity.

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 boolean
public boolean
public <KK extends K, VV extends V> boolean
public boolean
putAllPairs(Pair<? extends K, ? extends V>... pairs)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.putAllPairs.

public boolean
putAllPairs(Iterable<? extends Pair<? extends K, ? extends V>> pairs)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.putAllPairs.

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 boolean
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 int
size()

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

Returns the number of key-value entry pairs.

public int
sizeDistinct()

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

Returns the number of distinct keys.

public MutableMap<K, RichIterable<V>>
toMap()

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

Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.

public <R extends Collection<V>> MutableMap<K, R>
toMap(Function0<R> collectionFactory)

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

Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public RichIterable<V>
valuesView()

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

Returns a lazy flattened view of all the values.

public MutableMultimap<K, V>
withKeyMultiValues(K key, V... values)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.withKeyMultiValues.

Puts the key / values combination into the MutableMultimap and returns the MutableMultimap (this).

protected Object
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

delegateback to summary
protected final MutableMultimap<K, V> delegate
lockback to summary
private final Object lock

Constructor Detail

AbstractSynchronizedMultimapback to summary
protected AbstractSynchronizedMultimap(MutableMultimap<K, V> multimap, Object newLock)
AbstractSynchronizedMultimapback to summary
protected AbstractSynchronizedMultimap(MutableMultimap<K, V> multimap)

Method Detail

addback to summary
public boolean add(Pair<? extends K, ? extends V> keyValuePair)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.add.

Doc from org.eclipse.collections.api.multimap.MutableMultimap.add.

Modification operation similar to put, however, takes the key-value pair as the input.

Annotations
@Override
clearback to summary
public void clear()

Implements org.eclipse.collections.api.multimap.MutableMultimap.clear.

Annotations
@Override
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
equalsback to summary
public boolean equals(Object obj)

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
getDelegateback to summary
protected MutableMultimap<K, V> getDelegate()
getLockback to summary
protected Object getLock()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

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

Doc from 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 toMap.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

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

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

Returns true if there are no entries.

Annotations
@Override
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
keySetback to summary
public SetIterable<K> keySet()

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

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

Returns an unmodifiable SetIterable of keys with O(1) complexity.

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
putback to summary
public boolean put(K key, V value)

Implements org.eclipse.collections.api.multimap.MutableMultimap.put.

Annotations
@Override
putAllback to summary
public boolean putAll(K key, Iterable<? extends V> values)

Implements org.eclipse.collections.api.multimap.MutableMultimap.putAll.

Annotations
@Override
putAllback to summary
public <KK extends K, VV extends V> boolean putAll(Multimap<KK, VV> multimap)

Implements org.eclipse.collections.api.multimap.MutableMultimap.putAll.

Annotations
@Override
putAllPairsback to summary
public boolean putAllPairs(Pair<? extends K, ? extends V>... pairs)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.putAllPairs.

Annotations
@Override
putAllPairsback to summary
public boolean putAllPairs(Iterable<? extends Pair<? extends K, ? extends V>> pairs)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.putAllPairs.

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
removeback to summary
public boolean remove(Object key, Object value)

Implements org.eclipse.collections.api.multimap.MutableMultimap.remove.

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
sizeback to summary
public int size()

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

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

Returns the number of key-value entry pairs.

This method is implemented with O(1) (constant-time) performance.

Annotations
@Override
sizeDistinctback to summary
public int sizeDistinct()

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

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

Returns the number of distinct keys.

Annotations
@Override
toMapback to summary
public MutableMap<K, RichIterable<V>> toMap()

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

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

Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.

Annotations
@Override
toMapback to summary
public <R extends Collection<V>> MutableMap<K, R> toMap(Function0<R> collectionFactory)

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

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

Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

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
withKeyMultiValuesback to summary
public MutableMultimap<K, V> withKeyMultiValues(K key, V... values)

Overrides default org.eclipse.collections.api.multimap.MutableMultimap.withKeyMultiValues.

Doc from org.eclipse.collections.api.multimap.MutableMultimap.withKeyMultiValues.

Puts the key / values combination into the MutableMultimap and returns the MutableMultimap (this).

Annotations
@Override
writeReplaceback to summary
protected Object writeReplace()