Top Fields Constructors Methods
org.eclipse.collections.impl.map.immutable

public Class ImmutableUnifiedMap<K, V>

extends AbstractImmutableMap<K, V>
implements BatchIterable<V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.eclipse.collections.impl.parallel.BatchIterable
Imports
java.io.Serializable, java.util.Collection, .Map, .Set, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.block.function.Function, .Function0, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.map.ImmutableMap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.collection.mutable.UnmodifiableMutableCollection, org.eclipse.collections.impl.map.mutable.UnifiedMap, org.eclipse.collections.impl.parallel.BatchIterable, org.eclipse.collections.impl.set.mutable.UnmodifiableMutableSet

See Also
ImmutableMap

Field Summary

Modifier and TypeField and Description
private final UnifiedMap<K, V>
private static final long

Constructor Summary

AccessConstructor and Description
public
ImmutableUnifiedMap(Map<? extends K, ? extends V> delegate)

public
ImmutableUnifiedMap(Pair<K, V>... pairs)

Method Summary

Modifier and TypeMethod and Description
public void
batchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount)

Implements org.eclipse.collections.impl.parallel.BatchIterable.batchForEach.

public boolean
containsKey(Object key)

Implements org.eclipse.collections.api.map.MapIterable.containsKey, java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

public boolean
containsValue(Object value)

Implements org.eclipse.collections.api.map.MapIterable.containsValue, java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.

public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.map.MapIterable.equals, java.util.Map.equals.

Compares the specified object with this map for equality.

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

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachKey.

Implements org.eclipse.collections.api.map.MapIterable.forEachKey.

Calls the procedure with each key of the map.

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

Implements org.eclipse.collections.api.map.MapIterable.forEachKeyValue.

Calls the procedure with each key-value pair of the map.

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

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachValue.

Implements org.eclipse.collections.api.map.MapIterable.forEachValue.

Calls the procedure with each value of the map.

public <P> void
forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

public void
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

public V
get(Object key)

Implements org.eclipse.collections.api.map.MapIterable.get, java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

public int
public V
getIfAbsent(K key, Function0<? extends V> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsent.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsent.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function0.

public V
getIfAbsentValue(K key, V value)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsentValue.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsentValue.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return value.

public <P> V
getIfAbsentWith(K key, Function<? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsentWith.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsentWith.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified function and parameter.

public int
public <A> A
ifPresentApply(K key, Function<? super V, ? extends A> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.ifPresentApply.

Implements org.eclipse.collections.api.map.MapIterable.ifPresentApply.

If there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.

public Set<K>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.

public RichIterable<K>
keysView()

Implements org.eclipse.collections.api.map.MapIterable.keysView.

Returns an unmodifiable lazy iterable wrapped around the keySet for the map.

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

Implements org.eclipse.collections.api.map.MapIterable.keyValuesView.

Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.

public int
public String
toString()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toString.

Implements org.eclipse.collections.api.map.MapIterable.toString, org.eclipse.collections.api.RichIterable.toString.

Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces.

public Collection<V>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.

public RichIterable<V>
valuesView()

Implements org.eclipse.collections.api.map.MapIterable.valuesView.

Returns an unmodifiable lazy iterable wrapped around the values for the map.

protected Object
Inherited from org.eclipse.collections.impl.map.immutable.AbstractImmutableMap:
aggregateBycastToMapclearcollectcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectKeysUniquecollectLongcollectShortcollectValuescollectWithcountBycountByEachcountByWithdetectdetectOptionalentrySetflatCollectflipflipUniqueValuesforEachgroupBygroupByEachgroupByUniqueKeyiteratornewWithAllKeyValueArgumentsnewWithAllKeyValuesnewWithKeyValuenewWithMapnewWithMapIterablenewWithoutAllKeysnewWithoutKeypartitionpartitionWithputputAllrejectrejectrejectWithremoveselectselectselectInstancesOfselectWithsumByDoublesumByFloatsumByIntsumByLongtaptoImmutabletoMapzipzipWithIndex

Field Detail

delegateback to summary
private final UnifiedMap<K, V> delegate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ImmutableUnifiedMapback to summary
public ImmutableUnifiedMap(Map<? extends K, ? extends V> delegate)
ImmutableUnifiedMapback to summary
public ImmutableUnifiedMap(Pair<K, V>... pairs)

Method Detail

batchForEachback to summary
public void batchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount)

Implements org.eclipse.collections.impl.parallel.BatchIterable.batchForEach.

Annotations
@Override
containsKeyback to summary
public boolean containsKey(Object key)

Implements org.eclipse.collections.api.map.MapIterable.containsKey, java.util.Map.containsKey.

Doc from java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)

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

Implements org.eclipse.collections.api.map.MapIterable.containsValue, java.util.Map.containsValue.

Doc from java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that Objects.equals(value, v). This operation will probably require time linear in the map size for most implementations of the Map interface.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements org.eclipse.collections.api.map.MapIterable.equals, java.util.Map.equals.

Doc from java.util.Map.equals.

Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.

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

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachKey.

Implements org.eclipse.collections.api.map.MapIterable.forEachKey.

Doc from org.eclipse.collections.api.map.MapIterable.forEachKey.

Calls the procedure with each key of the map.

    final Collection<Integer> result = new ArrayList<Integer>();
    MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
    map.forEachKey(new CollectionAddProcedure<Integer>(result));
    Verify.assertContainsAll(result, 1, 2, 3);
Annotations
@Override
forEachKeyValueback to summary
public void forEachKeyValue(Procedure2<? super K, ? super V> procedure)

Implements org.eclipse.collections.api.map.MapIterable.forEachKeyValue.

Doc from org.eclipse.collections.api.map.MapIterable.forEachKeyValue.

Calls the procedure with each key-value pair of the map.

    final Collection<String> collection = new ArrayList<String>();
    MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
    map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
    Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
Annotations
@Override
forEachValueback to summary
public void forEachValue(Procedure<? super V> procedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachValue.

Implements org.eclipse.collections.api.map.MapIterable.forEachValue.

Doc from org.eclipse.collections.api.map.MapIterable.forEachValue.

Calls the procedure with each value of the map.

    Set<String> result = UnifiedSet.newSet();
    MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three", 4, "Four");
    map.forEachValue(new CollectionAddProcedure<String>(result));
    Verify.assertSetsEqual(UnifiedSet.newSetWith("One", "Two", "Three", "Four"), result);
Annotations
@Override
forEachWithback to summary
public <P> void forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

Doc from org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

Example using a Java 8 lambda:

people.forEachWith((Person person, Person other) ->
    {
        if (person.isRelatedTo(other))
        {
             LOGGER.info(person.getName());
        }
    }, fred);

Example using an anonymous inner class:

people.forEachWith(new Procedure2<Person, Person>()
{
    public void value(Person person, Person other)
    {
        if (person.isRelatedTo(other))
        {
             LOGGER.info(person.getName());
        }
    }
}, fred);
Annotations
@Override
forEachWithIndexback to summary
public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Doc from org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

Example using a Java 8 lambda:

people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));

Example using an anonymous inner class:

people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
    public void value(Person person, int index)
    {
        LOGGER.info("Index: " + index + " person: " + person.getName());
    }
});
Annotations
@Override
getback to summary
public V get(Object key)

Implements org.eclipse.collections.api.map.MapIterable.get, java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Annotations
@Override
getBatchCountback to summary
public int getBatchCount(int batchSize)

Implements org.eclipse.collections.impl.parallel.BatchIterable.getBatchCount.

Annotations
@Override
getIfAbsentback to summary
public V getIfAbsent(K key, Function0<? extends V> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsent.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsent.

Doc from org.eclipse.collections.api.map.MapIterable.getIfAbsent.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function0.

Annotations
@Override
getIfAbsentValueback to summary
public V getIfAbsentValue(K key, V value)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsentValue.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsentValue.

Doc from org.eclipse.collections.api.map.MapIterable.getIfAbsentValue.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return value.

Annotations
@Override
getIfAbsentWithback to summary
public <P> V getIfAbsentWith(K key, Function<? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsentWith.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsentWith.

Doc from org.eclipse.collections.api.map.MapIterable.getIfAbsentWith.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified function and parameter.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.eclipse.collections.api.map.MapIterable.hashCode, java.util.Map.hashCode.

Doc from java.util.Map.hashCode.

Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object#hashCode.

Annotations
@Override
ifPresentApplyback to summary
public <A> A ifPresentApply(K key, Function<? super V, ? extends A> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.ifPresentApply.

Implements org.eclipse.collections.api.map.MapIterable.ifPresentApply.

Doc from org.eclipse.collections.api.map.MapIterable.ifPresentApply.

If there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.

Annotations
@Override
keySetback to summary
public Set<K> keySet()

Implements java.util.Map.keySet.

Doc from java.util.Map.keySet.

Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

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

Implements org.eclipse.collections.api.map.MapIterable.keysView.

Doc from org.eclipse.collections.api.map.MapIterable.keysView.

Returns an unmodifiable lazy iterable wrapped around the keySet for the map.

Annotations
@Override
keyValuesViewback to summary
public RichIterable<Pair<K, V>> keyValuesView()

Implements org.eclipse.collections.api.map.MapIterable.keyValuesView.

Doc from org.eclipse.collections.api.map.MapIterable.keyValuesView.

Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.

Annotations
@Override
sizeback to summary
public int size()

Implements org.eclipse.collections.impl.parallel.BatchIterable.size, org.eclipse.collections.api.RichIterable.size, java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toString.

Implements org.eclipse.collections.api.map.MapIterable.toString, org.eclipse.collections.api.RichIterable.toString.

Doc from org.eclipse.collections.api.map.MapIterable.toString.

Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. Each key and value is separated by an equals sign.

Assert.assertEquals("{1=1, 2=2, 3=3}", Maps.mutable.with(1, 1, 2, 2, 3, 3).toString());
Annotations
@Override
valuesback to summary
public Collection<V> values()

Implements java.util.Map.values.

Doc from java.util.Map.values.

Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

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

Implements org.eclipse.collections.api.map.MapIterable.valuesView.

Doc from org.eclipse.collections.api.map.MapIterable.valuesView.

Returns an unmodifiable lazy iterable wrapped around the values for the map.

Annotations
@Override
writeReplaceback to summary
protected Object writeReplace()