java.io.Serializable
, java.lang.Iterable<K>
, InternalIterable<K>
, ImmutableMap<K,V>
, ImmutableMapIterable<K,V>
, MapIterable<K,V>
, UnsortedMapIterable<K,V>
, RichIterable<K>
, BatchIterable<V>
public class ImmutableUnifiedMapWithHashingStrategy<K,V> extends AbstractImmutableMap<K,V> implements BatchIterable<V>, java.io.Serializable
ImmutableMap
,
Serialized FormConstructor | Description |
---|---|
ImmutableUnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy,
Pair<K,V>... pairs) |
|
ImmutableUnifiedMapWithHashingStrategy(UnifiedMapWithHashingStrategy<K,V> delegate) |
Modifier and Type | Method | Description |
---|---|---|
void |
batchForEach(Procedure<? super V> procedure,
int sectionIndex,
int sectionCount) |
|
<R> ImmutableMap<K,R> |
collectValues(Function2<? super K,? super V,? extends R> function) |
For each key and value of the map the function is evaluated.
|
boolean |
containsKey(java.lang.Object key) |
|
boolean |
containsValue(java.lang.Object value) |
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
|
boolean |
equals(java.lang.Object o) |
Follows the same general contract as
Map.equals(Object) . |
void |
forEachKey(Procedure<? super K> procedure) |
Calls the
procedure with each key of the map. |
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure) |
Calls the
procedure with each key-value pair of the map. |
void |
forEachValue(Procedure<? super V> procedure) |
Calls the procedure with each value of the map.
|
<P> void |
forEachWith(Procedure2<? super V,? super P> procedure,
P parameter) |
The procedure2 is evaluated for each element in the iterable with the specified parameter provided
as the second argument.
|
void |
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) |
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure.
|
V |
get(java.lang.Object key) |
|
int |
getBatchCount(int batchSize) |
|
int |
hashCode() |
Follows the same general contract as
Map.hashCode() . |
java.util.Set<K> |
keySet() |
|
RichIterable<K> |
keysView() |
Returns an unmodifiable lazy iterable wrapped around the keySet for the map.
|
RichIterable<Pair<K,V>> |
keyValuesView() |
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
|
ImmutableMap<K,V> |
newWithAllKeyValueArguments(Pair<? extends K,? extends V>... keyValuePairs) |
|
ImmutableMap<K,V> |
newWithAllKeyValues(java.lang.Iterable<? extends Pair<? extends K,? extends V>> keyValues) |
|
ImmutableMap<K,V> |
newWithKeyValue(K key,
V value) |
|
ImmutableMap<K,V> |
newWithoutAllKeys(java.lang.Iterable<? extends K> keys) |
|
ImmutableMap<K,V> |
newWithoutKey(K key) |
|
ImmutableMap<K,V> |
reject(Predicate2<? super K,? super V> predicate) |
For each key and value of the map the predicate is evaluated, if the result of the evaluation is false,
that key and value are returned in a new map.
|
ImmutableMap<K,V> |
select(Predicate2<? super K,? super V> predicate) |
For each key and value of the map the predicate is evaluated, if the result of the evaluation is true,
that key and value are returned in a new map.
|
int |
size() |
Returns the number of items in this iterable.
|
java.lang.String |
toString() |
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
java.util.Collection<V> |
values() |
|
RichIterable<V> |
valuesView() |
Returns an unmodifiable lazy iterable wrapped around the values for the map.
|
aggregateBy, aggregateInPlaceBy, castToMap, clear, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, countBy, countByWith, detect, detectOptional, flatCollect, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, iterator, partition, partitionWith, put, putAll, reject, rejectWith, remove, select, selectInstancesOf, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, tap, toImmutable, toMap, zip, zipWithIndex
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArray
appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
forEach
forEach, forEach
compute, computeIfAbsent, computeIfPresent, entry, forEach, getOrDefault, isEmpty, merge, of, of, of, of, of, of, of, of, of, of, of, ofEntries, putIfAbsent, remove, replace, replace, replaceAll
getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, parallelStream, spliterator, stream
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
public ImmutableUnifiedMapWithHashingStrategy(UnifiedMapWithHashingStrategy<K,V> delegate)
public ImmutableUnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K,V>... pairs)
public boolean equals(java.lang.Object o)
MapIterable
Map.equals(Object)
.equals
in interface MapIterable<K,V>
equals
in class java.lang.Object
public int hashCode()
MapIterable
Map.hashCode()
.hashCode
in interface MapIterable<K,V>
hashCode
in class java.lang.Object
public java.lang.String toString()
AbstractRichIterable
Assert.assertEquals("[]", Lists.mutable.empty().toString()); Assert.assertEquals("[1]", Lists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
toString
in interface MapIterable<K,V>
toString
in interface RichIterable<K>
toString
in class AbstractRichIterable<V>
AbstractCollection.toString()
public int size()
RichIterable
size
in interface BatchIterable<K>
size
in interface RichIterable<K>
public boolean containsKey(java.lang.Object key)
containsKey
in interface MapIterable<K,V>
Map.containsKey(Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface MapIterable<K,V>
Map.containsValue(Object)
public V get(java.lang.Object key)
get
in interface MapIterable<K,V>
Map.get(Object)
public int getBatchCount(int batchSize)
getBatchCount
in interface BatchIterable<K>
public void batchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount)
batchForEach
in interface BatchIterable<K>
public void forEachValue(Procedure<? super V> procedure)
MapIterable
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);
forEachValue
in interface MapIterable<K,V>
forEachValue
in class AbstractMapIterable<K,V>
public void forEachKey(Procedure<? super K> procedure)
MapIterable
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);
forEachKey
in interface MapIterable<K,V>
forEachKey
in class AbstractMapIterable<K,V>
public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
MapIterable
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");
forEachKeyValue
in interface MapIterable<K,V>
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in class AbstractImmutableMap<K,V>
public java.util.Set<K> keySet()
public java.util.Collection<V> values()
public RichIterable<K> keysView()
MapIterable
keysView
in interface MapIterable<K,V>
public RichIterable<V> valuesView()
MapIterable
valuesView
in interface MapIterable<K,V>
public RichIterable<Pair<K,V>> keyValuesView()
MapIterable
keyValuesView
in interface MapIterable<K,V>
public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)
InternalIterable
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()); } });
forEachWithIndex
in interface InternalIterable<K>
forEachWithIndex
in class AbstractMapIterable<K,V>
public <P> void forEachWith(Procedure2<? super V,? super P> procedure, P parameter)
InternalIterable
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);
forEachWith
in interface InternalIterable<K>
forEachWith
in class AbstractMapIterable<K,V>
public ImmutableMap<K,V> newWithKeyValue(K key, V value)
newWithKeyValue
in interface ImmutableMap<K,V>
newWithKeyValue
in interface ImmutableMapIterable<K,V>
newWithKeyValue
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> newWithAllKeyValues(java.lang.Iterable<? extends Pair<? extends K,? extends V>> keyValues)
newWithAllKeyValues
in interface ImmutableMap<K,V>
newWithAllKeyValues
in interface ImmutableMapIterable<K,V>
newWithAllKeyValues
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> newWithAllKeyValueArguments(Pair<? extends K,? extends V>... keyValuePairs)
newWithAllKeyValueArguments
in interface ImmutableMap<K,V>
newWithAllKeyValueArguments
in interface ImmutableMapIterable<K,V>
newWithAllKeyValueArguments
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> newWithoutKey(K key)
newWithoutKey
in interface ImmutableMap<K,V>
newWithoutKey
in interface ImmutableMapIterable<K,V>
newWithoutKey
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> newWithoutAllKeys(java.lang.Iterable<? extends K> keys)
newWithoutAllKeys
in interface ImmutableMap<K,V>
newWithoutAllKeys
in interface ImmutableMapIterable<K,V>
newWithoutAllKeys
in class AbstractImmutableMap<K,V>
public <R> ImmutableMap<K,R> collectValues(Function2<? super K,? super V,? extends R> function)
MapIterable
MapIterable<City, String> collected = peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());
collectValues
in interface ImmutableMap<K,V>
collectValues
in interface ImmutableMapIterable<K,V>
collectValues
in interface MapIterable<K,V>
collectValues
in interface UnsortedMapIterable<K,V>
collectValues
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> select(Predicate2<? super K,? super V> predicate)
MapIterable
MapIterable<City, Person> selected = peopleByCity.select((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
select
in interface ImmutableMap<K,V>
select
in interface ImmutableMapIterable<K,V>
select
in interface MapIterable<K,V>
select
in interface UnsortedMapIterable<K,V>
select
in class AbstractImmutableMap<K,V>
public ImmutableMap<K,V> reject(Predicate2<? super K,? super V> predicate)
MapIterable
MapIterable<City, Person> rejected = peopleByCity.reject((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
reject
in interface ImmutableMap<K,V>
reject
in interface ImmutableMapIterable<K,V>
reject
in interface MapIterable<K,V>
reject
in interface UnsortedMapIterable<K,V>
reject
in class AbstractImmutableMap<K,V>
Copyright © 2004–2017. All rights reserved.