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

public Class SynchronizedBagMultimap<K, V>

extends AbstractSynchronizedMultimap<K, V>
implements MutableBagMultimap<K, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.eclipse.collections.api.multimap.bag.MutableBagMultimap, org.eclipse.collections.api.multimap.bag.UnsortedBagMultimap, org.eclipse.collections.api.multimap.bag.BagMultimap, org.eclipse.collections.api.multimap.Multimap, org.eclipse.collections.api.multimap.bag.MutableBagIterableMultimap, org.eclipse.collections.api.multimap.MutableMultimap
Imports
java.io.Serializable, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.predicate.Predicate2, org.eclipse.collections.api.block.procedure.Procedure2, org.eclipse.collections.api.multimap.bag.ImmutableBagMultimap, .MutableBagMultimap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.multimap.AbstractSynchronizedMultimap

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from org.eclipse.collections.impl.multimap.AbstractSynchronizedMultimap:
delegate

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

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

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectKeyMultiValues, org.eclipse.collections.api.multimap.MutableMultimap.collectKeyMultiValues.

Returns a new multimap with the results of applying the specified keyFunction and valueFunction on each key and corresponding values of the source multimap.

public <K2, V2> MutableBagMultimap<K2, V2>
collectKeysValues(Function2<? super K, ? super V, Pair<K2, V2>> function)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.collectKeysValues.

Returns a new multimap with the results of applying the specified function on each key and value of the source multimap.

public <V2> MutableBagMultimap<K, V2>
collectValues(Function<? super V, ? extends V2> function)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectValues, org.eclipse.collections.api.multimap.MutableMultimap.collectValues.

Returns a new multimap with the results of applying the specified function on each value of the source multimap.

public MutableBagMultimap<V, K>
flip()

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.flip, org.eclipse.collections.api.multimap.MutableMultimap.flip.

Given a Multimap from Domain -> Range return a multimap from Range -> Domain.

public void
public MutableBag<V>
get(K key)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.get, org.eclipse.collections.api.multimap.MutableMultimap.get.

Returns a view of all values associated with the given key.

protected MutableBagMultimap<K, V>
public MutableBag<V>
getIfAbsentPutAll(K key, Iterable<? extends V> values)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.getIfAbsentPutAll, org.eclipse.collections.api.multimap.MutableMultimap.getIfAbsentPutAll.

Puts values into multimap if there are no values already associated with key.

public MutableBagMultimap<K, V>
newEmpty()

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.newEmpty, org.eclipse.collections.api.multimap.MutableMultimap.newEmpty.

Creates a new instance of the same implementation type, using the default capacity and growth parameters.

public static <K, V> SynchronizedBagMultimap<K, V>
of(MutableBagMultimap<K, V> multimap)

This method will take a Multimap and wrap it directly in a SynchronizedBagMultimap.

public static <K, V> SynchronizedBagMultimap<K, V>
of(MutableBagMultimap<K, V> multimap, Object lock)

This method will take a Multimap and wrap it directly in a SynchronizedBagMultimap.

public void
public MutableBagMultimap<K, V>
public MutableBagMultimap<K, V>
rejectKeysValues(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.rejectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.rejectKeysValues.

Returns all elements of the source multimap that don't satisfy the predicate.

public MutableBag<V>
public MutableBag<V>
public MutableBagMultimap<K, V>
public MutableBagMultimap<K, V>
selectKeysValues(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.selectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.selectKeysValues.

Returns all elements of the source multimap that satisfies the predicate.

public ImmutableBagMultimap<K, V>
public MutableBagMultimap<K, V>
public MutableBagMultimap<K, V>
Inherited from org.eclipse.collections.impl.multimap.AbstractSynchronizedMultimap:
addclearcollectKeyMultiValuescollectKeysValuescollectValuescontainsKeycontainsKeyAndValuecontainsValueequalsforEachKeyforEachKeyMultiValuesforEachKeyValueforEachValuegetLockhashCodeisEmptykeyBagkeyMultiValuePairsViewkeySetkeysViewkeyValuePairsViewmultiValuesViewnotEmptyputputAllputAllputAllPairsputAllPairsrejectKeysMultiValuesrejectKeysValuesremoveselectKeysMultiValuesselectKeysValuessizesizeDistincttoMaptoMaptoStringvaluesViewwriteReplace

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SynchronizedBagMultimapback to summary
public SynchronizedBagMultimap(MutableBagMultimap<K, V> multimap)
SynchronizedBagMultimapback to summary
public SynchronizedBagMultimap(MutableBagMultimap<K, V> multimap, Object newLock)

Method Detail

asSynchronizedback to summary
public MutableBagMultimap<K, V> asSynchronized()

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.asSynchronized, org.eclipse.collections.api.multimap.MutableMultimap.asSynchronized.

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

Returns a synchronized wrapper backed by this multimap. The preferred way of iterating over a synchronized multimap is to use the forEachKey(), forEachValue(), forEachKeyValue() and forEachKeyMultiValues methods which are properly synchronized internally.

 MutableMultimap synchedMultimap = multimap.asSynchronized();

 synchedMultimap.forEachKey(key -> ... );
 synchedMultimap.forEachValue(value -> ... );
 synchedMultimap.forEachKeyValue((key, value) -> ... );
 synchedMultimap.forEachKeyMultiValues((key, values) -> ... );

If you want to iterate imperatively over the keySet(), keysView(), valuesView(), or other views, you will need to protect the iteration by wrapping the code in a synchronized block on the multimap.

Annotations
@Override
collectKeyMultiValuesback to summary
public <K2, V2> MutableBagMultimap<K2, V2> collectKeyMultiValues(Function<? super K, ? extends K2> keyFunction, Function<? super V, ? extends V2> valueFunction)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectKeyMultiValues, org.eclipse.collections.api.multimap.MutableMultimap.collectKeyMultiValues.

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

Returns a new multimap with the results of applying the specified keyFunction and valueFunction on each key and corresponding values of the source multimap. This method is also commonly called transform or map.

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

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.collectKeysValues.

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

Returns a new multimap with the results of applying the specified function on each key and value of the source multimap. This method is also commonly called transform or map.

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());
    }
});
Annotations
@Override
collectValuesback to summary
public <V2> MutableBagMultimap<K, V2> collectValues(Function<? super V, ? extends V2> function)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.collectValues, org.eclipse.collections.api.multimap.MutableMultimap.collectValues.

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

Returns a new multimap with the results of applying the specified function on each value of the source multimap. This method is also commonly called transform or map.

e.g.
return multimap.collectValues(new Function<Person, String>()
{
    public String valueOf(Person person)
    {
        return person.getLastName();
    }
});
Annotations
@Override
flipback to summary
public MutableBagMultimap<V, K> flip()

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.flip, org.eclipse.collections.api.multimap.MutableMultimap.flip.

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

Given a Multimap from Domain -> Range return a multimap from Range -> Domain.

Annotations
@Override
forEachKeyMutableBagback to summary
public void forEachKeyMutableBag(Procedure2<? super K, ? super MutableBag<V>> procedure)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.forEachKeyMutableBag.

Annotations
@Override
getback to summary
public MutableBag<V> get(K key)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.get, org.eclipse.collections.api.multimap.MutableMultimap.get.

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

Returns a view of all values associated with the given key.

If the given key does not exist, an empty RichIterable is returned.

Annotations
@Override
getDelegateback to summary
protected MutableBagMultimap<K, V> getDelegate()

Overrides org.eclipse.collections.impl.multimap.AbstractSynchronizedMultimap.getDelegate.

Annotations
@Override
getIfAbsentPutAllback to summary
public MutableBag<V> getIfAbsentPutAll(K key, Iterable<? extends V> values)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.getIfAbsentPutAll, org.eclipse.collections.api.multimap.MutableMultimap.getIfAbsentPutAll.

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

Puts values into multimap if there are no values already associated with key. Then returns a view of the values associated with key, like the result of Multimap#get(Object)

Annotations
@Override
newEmptyback to summary
public MutableBagMultimap<K, V> newEmpty()

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.newEmpty, org.eclipse.collections.api.multimap.MutableMultimap.newEmpty.

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

Creates a new instance of the same implementation type, using the default capacity and growth parameters.

Annotations
@Override
ofback to summary
public static <K, V> SynchronizedBagMultimap<K, V> of(MutableBagMultimap<K, V> multimap)

This method will take a Multimap and wrap it directly in a SynchronizedBagMultimap.

ofback to summary
public static <K, V> SynchronizedBagMultimap<K, V> of(MutableBagMultimap<K, V> multimap, Object lock)

This method will take a Multimap and wrap it directly in a SynchronizedBagMultimap. Additionally, a developer specifies which lock to use with the collection.

putOccurrencesback to summary
public void putOccurrences(K key, V value, int occurrences)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.putOccurrences.

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

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.rejectKeysMultiValues, org.eclipse.collections.api.multimap.MutableMultimap.rejectKeysMultiValues.

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

Returns all elements of the source multimap that don't satisfy the predicate.

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);
    }
});
Annotations
@Override
rejectKeysValuesback to summary
public MutableBagMultimap<K, V> rejectKeysValues(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.rejectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.rejectKeysValues.

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

Returns all elements of the source multimap that don't satisfy the predicate.

e.g.
return multimap.rejectKeysValues(new Predicate2<Integer, Person>()
{
    public boolean accept(Integer age, Person person)
    {
        return (age >= 18)
                 && (person.getAddress().getCity().equals("Metuchen"));
    }
});
Annotations
@Override
removeAllback to summary
public MutableBag<V> removeAll(Object key)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.removeAll, org.eclipse.collections.api.multimap.MutableMultimap.removeAll.

Annotations
@Override
replaceValuesback to summary
public MutableBag<V> replaceValues(K key, Iterable<? extends V> values)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.replaceValues, org.eclipse.collections.api.multimap.MutableMultimap.replaceValues.

Annotations
@Override
selectKeysMultiValuesback to summary
public MutableBagMultimap<K, V> selectKeysMultiValues(Predicate2<? super K, ? super RichIterable<V>> predicate)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.selectKeysMultiValues, org.eclipse.collections.api.multimap.MutableMultimap.selectKeysMultiValues.

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

Returns all elements of the source multimap that satisfies the predicate. This method is also commonly called filter.

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);
    }
});
Annotations
@Override
selectKeysValuesback to summary
public MutableBagMultimap<K, V> selectKeysValues(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.multimap.bag.MutableBagMultimap.selectKeysValues, org.eclipse.collections.api.multimap.MutableMultimap.selectKeysValues.

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

Returns all elements of the source multimap that satisfies the predicate. This method is also commonly called filter.

e.g.
return multimap.selectKeysValues(new Predicate2<Integer, Person>()
{
    public boolean accept(Integer age, Person person)
    {
        return (age >= 18)
                 && (person.getAddress().getCity().equals("Metuchen"));
    }
});
Annotations
@Override
toImmutableback to summary
public ImmutableBagMultimap<K, V> toImmutable()

Implements org.eclipse.collections.api.multimap.Multimap.toImmutable, org.eclipse.collections.api.multimap.bag.UnsortedBagMultimap.toImmutable.

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

Returns an immutable copy of this Multimap if it is not already immutable. If the Multimap is immutable, it will return itself.

The returned Multimap will be Serializable if this Multimap is Serializable.

Annotations
@Override
toMutableback to summary
public MutableBagMultimap<K, V> toMutable()

Implements org.eclipse.collections.api.multimap.Multimap.toMutable, org.eclipse.collections.api.multimap.bag.UnsortedBagMultimap.toMutable.

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

Returns a mutable copy of this Multimap.

Annotations
@Override
withKeyMultiValuesback to summary
public MutableBagMultimap<K, V> withKeyMultiValues(K key, V... values)

Overrides org.eclipse.collections.impl.multimap.AbstractSynchronizedMultimap.withKeyMultiValues.

Overrides default org.eclipse.collections.api.multimap.bag.MutableBagMultimap.withKeyMultiValues, 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