@Immutable public class ImmutableUnifiedMapWithHashingStrategy<K,V> extends AbstractImmutableMap<K,V> implements BatchIterable<V>, java.io.Serializable
| Constructor and Description |
|---|
ImmutableUnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
com.gs.collections.api.tuple.Pair<K,V>... pairs) |
ImmutableUnifiedMapWithHashingStrategy(UnifiedMapWithHashingStrategy<K,V> delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
batchForEach(com.gs.collections.api.block.procedure.Procedure<? super V> procedure,
int sectionIndex,
int sectionCount) |
<R> com.gs.collections.api.map.ImmutableMap<K,R> |
collectValues(com.gs.collections.api.block.function.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(com.gs.collections.api.block.procedure.Procedure<? super K> procedure)
Calls the
procedure with each key of the map. |
void |
forEachKeyValue(com.gs.collections.api.block.procedure.Procedure2<? super K,? super V> procedure)
Calls the
procedure with each key-value pair of the map. |
void |
forEachValue(com.gs.collections.api.block.procedure.Procedure<? super V> procedure)
Calls the procedure with each value of the map.
|
<P> void |
forEachWith(com.gs.collections.api.block.procedure.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(com.gs.collections.api.block.procedure.primitive.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() |
com.gs.collections.api.RichIterable<K> |
keysView()
Returns an unmodifiable lazy iterable wrapped around the keySet for the map
|
com.gs.collections.api.RichIterable<com.gs.collections.api.tuple.Pair<K,V>> |
keyValuesView()
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map
|
com.gs.collections.api.map.ImmutableMap<K,V> |
newWithAllKeyValueArguments(com.gs.collections.api.tuple.Pair<? extends K,? extends V>... keyValuePairs) |
com.gs.collections.api.map.ImmutableMap<K,V> |
newWithAllKeyValues(java.lang.Iterable<? extends com.gs.collections.api.tuple.Pair<? extends K,? extends V>> keyValues) |
com.gs.collections.api.map.ImmutableMap<K,V> |
newWithKeyValue(K key,
V value) |
com.gs.collections.api.map.ImmutableMap<K,V> |
newWithoutAllKeys(java.lang.Iterable<? extends K> keys) |
com.gs.collections.api.map.ImmutableMap<K,V> |
newWithoutKey(K key) |
com.gs.collections.api.map.ImmutableMap<K,V> |
reject(com.gs.collections.api.block.predicate.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.
|
com.gs.collections.api.map.ImmutableMap<K,V> |
select(com.gs.collections.api.block.predicate.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 representation of this collection.
|
java.util.Collection<V> |
values() |
com.gs.collections.api.RichIterable<V> |
valuesView()
Returns an unmodifiable lazy iterable wrapped around the values for the map
|
protected java.lang.Object |
writeReplace() |
aggregateBy, aggregateInPlaceBy, castToMap, clear, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, detect, flatCollect, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, iterator, partition, partitionWith, put, putAll, reject, rejectWith, remove, select, selectInstancesOf, selectWith, tap, toImmutable, toMap, zip, zipWithIndexallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectWith, detectWithIfNone, each, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, ifPresentApply, isAbsent, keyAndValueEquals, keyAndValueHashCode, noneSatisfy, noneSatisfyWith, toArray, toArrayappendString, 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, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEachgetIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApplyallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexpublic ImmutableUnifiedMapWithHashingStrategy(UnifiedMapWithHashingStrategy<K,V> delegate)
public boolean equals(java.lang.Object o)
com.gs.collections.api.map.MapIterableMap.equals(Object).public int hashCode()
com.gs.collections.api.map.MapIterableMap.hashCode().public java.lang.String toString()
AbstractRichIterable
This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.
public int size()
com.gs.collections.api.RichIterablepublic boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public V get(java.lang.Object key)
public int getBatchCount(int batchSize)
getBatchCount in interface BatchIterable<V>public void batchForEach(com.gs.collections.api.block.procedure.Procedure<? super V> procedure, int sectionIndex, int sectionCount)
batchForEach in interface BatchIterable<V>public void forEachValue(com.gs.collections.api.block.procedure.Procedure<? super V> procedure)
com.gs.collections.api.map.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 com.gs.collections.api.map.MapIterable<K,V>forEachValue in class AbstractMapIterable<K,V>public void forEachKey(com.gs.collections.api.block.procedure.Procedure<? super K> procedure)
com.gs.collections.api.map.MapIterableprocedure 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 com.gs.collections.api.map.MapIterable<K,V>forEachKey in class AbstractMapIterable<K,V>public void forEachKeyValue(com.gs.collections.api.block.procedure.Procedure2<? super K,? super V> procedure)
com.gs.collections.api.map.MapIterableprocedure 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(new Procedure2<Integer, String>()
{
public void value(final Integer key, final String value)
{
collection.add(String.valueOf(key) + value);
}
});
Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
public com.gs.collections.api.RichIterable<K> keysView()
com.gs.collections.api.map.MapIterablepublic com.gs.collections.api.RichIterable<V> valuesView()
com.gs.collections.api.map.MapIterablepublic com.gs.collections.api.RichIterable<com.gs.collections.api.tuple.Pair<K,V>> keyValuesView()
com.gs.collections.api.map.MapIterablepublic void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super V> objectIntProcedure)
com.gs.collections.api.InternalIterableExample 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() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex in interface com.gs.collections.api.InternalIterable<V>forEachWithIndex in class AbstractMapIterable<K,V>public <P> void forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super V,? super P> procedure, P parameter)
com.gs.collections.api.InternalIterableExample 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() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith in interface com.gs.collections.api.InternalIterable<V>forEachWith in class AbstractMapIterable<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> newWithKeyValue(K key, V value)
newWithKeyValue in interface com.gs.collections.api.map.ImmutableMap<K,V>newWithKeyValue in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>newWithKeyValue in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> newWithAllKeyValues(java.lang.Iterable<? extends com.gs.collections.api.tuple.Pair<? extends K,? extends V>> keyValues)
newWithAllKeyValues in interface com.gs.collections.api.map.ImmutableMap<K,V>newWithAllKeyValues in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>newWithAllKeyValues in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> newWithAllKeyValueArguments(com.gs.collections.api.tuple.Pair<? extends K,? extends V>... keyValuePairs)
newWithAllKeyValueArguments in interface com.gs.collections.api.map.ImmutableMap<K,V>newWithAllKeyValueArguments in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>newWithAllKeyValueArguments in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> newWithoutKey(K key)
newWithoutKey in interface com.gs.collections.api.map.ImmutableMap<K,V>newWithoutKey in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>newWithoutKey in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> newWithoutAllKeys(java.lang.Iterable<? extends K> keys)
newWithoutAllKeys in interface com.gs.collections.api.map.ImmutableMap<K,V>newWithoutAllKeys in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>newWithoutAllKeys in class AbstractImmutableMap<K,V>public <R> com.gs.collections.api.map.ImmutableMap<K,R> collectValues(com.gs.collections.api.block.function.Function2<? super K,? super V,? extends R> function)
com.gs.collections.api.map.MapIterable
e.g.
peopleByCity.collectValues(new Function2<City, Person, String>()
{
public String value(City city, Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
});
collectValues in interface com.gs.collections.api.map.ImmutableMap<K,V>collectValues in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>collectValues in interface com.gs.collections.api.map.MapIterable<K,V>collectValues in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>collectValues in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> select(com.gs.collections.api.block.predicate.Predicate2<? super K,? super V> predicate)
com.gs.collections.api.map.MapIterable
e.g.
peopleByCity.select(new Predicate2<City, Person>()
{
public boolean accept(City city, Person person)
{
return city.getName().equals("Anytown") && person.getLastName().equals("Smith");
}
});
select in interface com.gs.collections.api.map.ImmutableMap<K,V>select in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>select in interface com.gs.collections.api.map.MapIterable<K,V>select in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>select in class AbstractImmutableMap<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> reject(com.gs.collections.api.block.predicate.Predicate2<? super K,? super V> predicate)
com.gs.collections.api.map.MapIterable
e.g.
peopleByCity.reject(new Predicate2<City, Person>()
{
public boolean accept(City city, Person person)
{
return city.getName().equals("Anytown") && person.getLastName().equals("Smith");
}
});
reject in interface com.gs.collections.api.map.ImmutableMap<K,V>reject in interface com.gs.collections.api.map.ImmutableMapIterable<K,V>reject in interface com.gs.collections.api.map.MapIterable<K,V>reject in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>reject in class AbstractImmutableMap<K,V>protected java.lang.Object writeReplace()