Class UnifiedMapWithHashingStrategy<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMap<K,V>
org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy<K,V>
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,Iterable<V>,Map<K,V>,InternalIterable<V>,MapIterable<K,V>,MutableMap<K,V>,MutableMapIterable<K,V>,UnsortedMapIterable<K,V>,RichIterable<V>,BatchIterable<V>
public class UnifiedMapWithHashingStrategy<K,V> extends AbstractMutableMap<K,V> implements Externalizable, BatchIterable<V>
UnifiedMapWithHashingStrategy stores key/value pairs in a single array, where alternate slots are keys and values.
This is nicer to CPU caches as consecutive memory addresses are very cheap to access. Entry objects are not stored in the
table like in java.util.HashMap. Instead of trying to deal with collisions in the main array using Entry objects,
we put a special object in the key slot and put a regular Object[] in the value slot. The array contains the key value
pairs in consecutive slots, just like the main array, but it's a linear list with no hashing.
The difference between UnifiedMap and UnifiedMapWithHashingStrategy is that a HashingStrategy based UnifiedMap does not rely on the hashCode or equality of the object at the key, but instead relies on a HashingStrategy implementation provided by a developer to compute the hashCode and equals for the objects stored in the map.
- See Also:
- Serialized Form
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description UnifiedMapWithHashingStrategy()Deprecated.No argument default constructor used for serialization.UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy)UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity)UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity, float loadFactor)UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Map<? extends K,? extends V> map)UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K,V>... pairs) -
Method Summary
Modifier and Type Method Description voidbatchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount)voidclear()UnifiedMapWithHashingStrategy<K,V>clone()<E> MutableMap<K,V>collectKeysAndValues(Iterable<E> iterable, Function<? super E,? extends K> keyFunction, Function<? super E,? extends V> valueFunction)Adds all the entries derived fromiterabletothis.<R> MutableMap<K,R>collectValues(Function2<? super K,? super V,? extends R> function)For each key and value of the map the function is evaluated.booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()booleanequals(Object object)Follows the same general contract asMap.equals(Object).voidforEachKey(Procedure<? super K> procedure)Calls theprocedurewith each key of the map.voidforEachKeyValue(Procedure2<? super K,? super V> procedure)Calls theprocedurewith each key-value pair of the map.voidforEachValue(Procedure<? super V> procedure)Calls the procedure with each value of the map.<P> voidforEachWith(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.voidforEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Vget(Object key)intgetBatchCount(int batchSize)intgetCollidingBuckets()VgetFirst()Returns the first element of an iterable.VgetIfAbsentPut(K key, Function0<? extends V> function)Get and return the value in the Map at the specified key.VgetIfAbsentPut(K key, V value)Get and return the value in the Map at the specified key.<P> VgetIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)Get and return the value in the Map at the specified key.intgetMapMemoryUsedInWords()Returns the number of JVM words that is used by this map.inthashCode()Follows the same general contract asMap.hashCode().HashingStrategy<? super K>hashingStrategy()booleanisEmpty()Returns true if this iterable has zero items.Set<K>keySet()MutableMap<K,V>newEmpty()Creates a new instance of the same type, using the default capacity and growth parameters.MutableMap<K,V>newEmpty(int capacity)Creates a new instance of the same type, using the given capacity and the default growth parameters.static <K, V> UnifiedMapWithHashingStrategy<K,V>newMap(HashingStrategy<? super K> hashingStrategy)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMap(HashingStrategy<? super K> hashingStrategy, int size)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMap(HashingStrategy<? super K> hashingStrategy, int size, float loadFactor)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMap(HashingStrategy<? super K> hashingStrategy, Map<? extends K,? extends V> map)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMap(UnifiedMapWithHashingStrategy<K,V> map)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMapWith(HashingStrategy<? super K> hashingStrategy, Iterable<Pair<K,V>> inputIterable)static <K, V> UnifiedMapWithHashingStrategy<K,V>newMapWith(HashingStrategy<? super K> hashingStrategy, Pair<K,V>... pairs)static <K, V> UnifiedMapWithHashingStrategy<K,V>newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key, V value)static <K, V> UnifiedMapWithHashingStrategy<K,V>newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2)static <K, V> UnifiedMapWithHashingStrategy<K,V>newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3)static <K, V> UnifiedMapWithHashingStrategy<K,V>newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)Vput(K key, V value)voidputAll(Map<? extends K,? extends V> map)voidreadExternal(ObjectInput in)Vremove(Object key)VremoveKey(K key)Remove an entry from the map at the specifiedkey.intsize()Returns the number of items in this iterable.ImmutableMap<K,V>toImmutable()Returns an immutable copy of this map.StringtoString()Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.booleantrimToSize()VupdateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)Looks up the value associated withkey, applies thefunctionto it, and replaces the value.<P> VupdateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)Same asMutableMapIterable.updateValue(Object, Function0, Function)with a Function2 and specified parameter which is passed to the function.Collection<V>values()UnifiedMapWithHashingStrategy<K,V>withKeysValues(K key, V value)UnifiedMapWithHashingStrategy<K,V>withKeysValues(K key1, V value1, K key2, V value2)UnifiedMapWithHashingStrategy<K,V>withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)UnifiedMapWithHashingStrategy<K,V>withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)voidwriteExternal(ObjectOutput out)Methods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMap
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexMethods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable
aggregateBy, aggregateInPlaceBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPutWithKey, iterator, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesViewMethods inherited from class org.eclipse.collections.impl.map.AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, getOrDefault, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArrayMethods inherited from class org.eclipse.collections.impl.AbstractRichIterable
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, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface org.eclipse.collections.api.map.MapIterable
detect, detectOptional, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewMethods inherited from interface org.eclipse.collections.api.map.MutableMap
aggregateBy, aggregateBy, aggregateInPlaceBy, collect, flatCollectWith, flipUniqueValues, withMapMethods inherited from interface org.eclipse.collections.api.map.MutableMapIterable
add, countBy, countByEach, countByWith, getIfAbsentPutWithKey, getOrDefault, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsBy, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, 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, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
-
Constructor Details
-
UnifiedMapWithHashingStrategy
Deprecated.No argument default constructor used for serialization. Instantiating an UnifiedMapWithHashingStrategyMultimap with this constructor will have a null hashingStrategy and throw NullPointerException when used. -
UnifiedMapWithHashingStrategy
-
UnifiedMapWithHashingStrategy
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity) -
UnifiedMapWithHashingStrategy
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, int initialCapacity, float loadFactor) -
UnifiedMapWithHashingStrategy
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Map<? extends K,? extends V> map) -
UnifiedMapWithHashingStrategy
public UnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K,V>... pairs)
-
-
Method Details
-
newMap
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMap(HashingStrategy<? super K> hashingStrategy) -
newMap
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMap(HashingStrategy<? super K> hashingStrategy, int size) -
newMap
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMap(HashingStrategy<? super K> hashingStrategy, int size, float loadFactor) -
newMap
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMap(HashingStrategy<? super K> hashingStrategy, Map<? extends K,? extends V> map) -
newMapWith
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMapWith(HashingStrategy<? super K> hashingStrategy, Iterable<Pair<K,V>> inputIterable) -
newMap
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMap(UnifiedMapWithHashingStrategy<K,V> map) -
newMapWith
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newMapWith(HashingStrategy<? super K> hashingStrategy, Pair<K,V>... pairs) -
newWithKeysValues
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key, V value) -
newWithKeysValues
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2) -
newWithKeysValues
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3) -
newWithKeysValues
public static <K, V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4) -
withKeysValues
-
withKeysValues
-
withKeysValues
-
withKeysValues
-
hashingStrategy
-
clone
- Specified by:
clonein interfaceMutableMap<K,V>- Specified by:
clonein classAbstractMutableMap<K,V>
-
newEmpty
Description copied from interface:MutableMapIterableCreates a new instance of the same type, using the default capacity and growth parameters.- Specified by:
newEmptyin interfaceMutableMap<K,V>- Specified by:
newEmptyin interfaceMutableMapIterable<K,V>
-
newEmpty
Description copied from class:AbstractMutableMapCreates a new instance of the same type, using the given capacity and the default growth parameters.- Specified by:
newEmptyin classAbstractMutableMap<K,V>
-
clear
public void clear() -
put
-
updateValue
public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)Description copied from interface:MutableMapIterableLooks up the value associated withkey, applies thefunctionto it, and replaces the value. If there is no value associated withkey, starts it off with a value supplied byfactory.- Specified by:
updateValuein interfaceMutableMapIterable<K,V>- Overrides:
updateValuein classAbstractMutableMapIterable<K,V>
-
updateValueWith
public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)Description copied from interface:MutableMapIterableSame asMutableMapIterable.updateValue(Object, Function0, Function)with a Function2 and specified parameter which is passed to the function.- Specified by:
updateValueWithin interfaceMutableMapIterable<K,V>- Overrides:
updateValueWithin classAbstractMutableMapIterable<K,V>
-
getIfAbsentPut
Description copied from interface:MutableMapIterableGet and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the result of evaluating the specified Function0, and put that value in the map at the specified key.- Specified by:
getIfAbsentPutin interfaceMutableMapIterable<K,V>- Overrides:
getIfAbsentPutin classAbstractMutableMapIterable<K,V>
-
getIfAbsentPut
Description copied from interface:MutableMapIterableGet and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the specified value, and put that value in the map at the specified key.- Specified by:
getIfAbsentPutin interfaceMutableMapIterable<K,V>- Overrides:
getIfAbsentPutin classAbstractMutableMapIterable<K,V>
-
getIfAbsentPutWith
Description copied from interface:MutableMapIterableGet and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key return the result of evaluating the specified Function using the specified parameter, and put that value in the map at the specified key.- Specified by:
getIfAbsentPutWithin interfaceMutableMapIterable<K,V>- Overrides:
getIfAbsentPutWithin classAbstractMutableMapIterable<K,V>
-
getCollidingBuckets
public int getCollidingBuckets() -
getMapMemoryUsedInWords
public int getMapMemoryUsedInWords()Returns the number of JVM words that is used by this map. A word is 4 bytes in a 32bit VM and 8 bytes in a 64bit VM. Each array has a 2 word header, thus the formula is: words = (internal table length + 2) + sum (for all chains (chain length + 2))- Returns:
- the number of JVM words that is used by this map.
-
get
- Specified by:
getin interfaceMap<K,V>- Specified by:
getin interfaceMapIterable<K,V>- See Also:
Map.get(Object)
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>- Specified by:
containsKeyin interfaceMapIterable<K,V>- See Also:
Map.containsKey(Object)
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>- Specified by:
containsValuein interfaceMapIterable<K,V>- See Also:
Map.containsValue(Object)
-
forEachKeyValue
Description copied from interface:MapIterableCalls theprocedurewith 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");- Specified by:
forEachKeyValuein interfaceMapIterable<K,V>
-
getFirst
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceRichIterable<K>- Overrides:
getFirstin classAbstractMapIterable<K,V>
-
collectKeysAndValues
public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E,? extends K> keyFunction, Function<? super E,? extends V> valueFunction)Description copied from interface:MutableMapAdds all the entries derived fromiterabletothis. The key and value for each entry is determined by applying thekeyFunctionandvalueFunctionto each item incollection. Any entry inmapthat has the same key as an entry inthiswill have its value replaced by that inmap.- Specified by:
collectKeysAndValuesin interfaceMutableMap<K,V>
-
removeKey
Description copied from interface:MutableMapIterableRemove an entry from the map at the specifiedkey.- Specified by:
removeKeyin interfaceMutableMapIterable<K,V>- Returns:
- The value removed from entry at key, or null if not found.
- See Also:
Map.remove(Object)
-
getBatchCount
public int getBatchCount(int batchSize)- Specified by:
getBatchCountin interfaceBatchIterable<K>
-
batchForEach
- Specified by:
batchForEachin interfaceBatchIterable<K>
-
forEachKey
Description copied from interface:MapIterableCalls theprocedurewith 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);- Specified by:
forEachKeyin interfaceMapIterable<K,V>- Overrides:
forEachKeyin classAbstractMapIterable<K,V>
-
forEachValue
Description copied from interface:MapIterableCalls 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);- Specified by:
forEachValuein interfaceMapIterable<K,V>- Overrides:
forEachValuein classAbstractMapIterable<K,V>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceMap<K,V>- Specified by:
isEmptyin interfaceRichIterable<K>- Overrides:
isEmptyin classAbstractRichIterable<V>
-
putAll
-
remove
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceBatchIterable<K>- Specified by:
sizein interfaceMap<K,V>- Specified by:
sizein interfaceRichIterable<K>
-
entrySet
-
keySet
-
values
-
equals
Description copied from interface:MapIterableFollows the same general contract asMap.equals(Object). -
hashCode
public int hashCode()Description copied from interface:MapIterableFollows the same general contract asMap.hashCode(). -
toString
Description copied from class:AbstractRichIterableReturns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.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());- Specified by:
toStringin interfaceMapIterable<K,V>- Specified by:
toStringin interfaceRichIterable<K>- Overrides:
toStringin classAbstractRichIterable<V>- Returns:
- a string representation of this collection.
- See Also:
AbstractCollection.toString()
-
trimToSize
public boolean trimToSize() -
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
forEachWithIndex
Description copied from interface:InternalIterableIterates 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()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<K>- Overrides:
forEachWithIndexin classAbstractMapIterable<K,V>
-
forEachWith
Description copied from interface:InternalIterableThe 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);- Specified by:
forEachWithin interfaceInternalIterable<K>- Overrides:
forEachWithin classAbstractMapIterable<K,V>
-
collectValues
Description copied from interface:MapIterableFor each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.MapIterable<City, String> collected = peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());- Specified by:
collectValuesin interfaceMapIterable<K,V>- Specified by:
collectValuesin interfaceMutableMap<K,V>- Specified by:
collectValuesin interfaceMutableMapIterable<K,V>- Specified by:
collectValuesin interfaceUnsortedMapIterable<K,V>- Overrides:
collectValuesin classAbstractMutableMap<K,V>
-
toImmutable
Description copied from interface:MutableMapIterableReturns an immutable copy of this map. If the map is immutable, it returns itself.- Specified by:
toImmutablein interfaceMapIterable<K,V>- Specified by:
toImmutablein interfaceMutableMapIterable<K,V>- Specified by:
toImmutablein interfaceUnsortedMapIterable<K,V>- Overrides:
toImmutablein classAbstractMutableMap<K,V>
-