public abstract class AbstractSynchronizedMapIterable<K,V> extends AbstractSynchronizedRichIterable<V> implements MutableMapIterable<K,V>
| Modifier and Type | Method and Description |
|---|---|
V |
add(Pair<K,V> keyValuePair)
This method allows mutable map the ability to add an element in the form of Pair
|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Pair<K,V> |
detect(Predicate2<? super K,? super V> predicate)
Return the first key and value of the map for which the predicate evaluates to true when they are given
as arguments.
|
void |
forEachKey(Procedure<? super K> procedure)
Calls the
procedure with each key of the map. |
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure2)
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.
|
V |
get(Object key) |
V |
getIfAbsent(K key,
Function0<? extends V> function)
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.
|
V |
getIfAbsentPut(K key,
Function0<? extends V> function)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentPut(K key,
V value)
Get and return the value in the Map at the specified key.
|
<P> V |
getIfAbsentPutWith(K key,
Function<? super P,? extends V> function,
P parameter)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentPutWithKey(K key,
Function<? super K,? extends V> function)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentValue(K key,
V value)
Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return
value. |
<P> V |
getIfAbsentWith(K key,
Function<? super P,? extends V> function,
P parameter)
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.
|
<A> A |
ifPresentApply(K key,
Function<? super V,? extends A> function)
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.
|
RichIterable<Pair<K,V>> |
keyValuesView()
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map
|
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
V |
remove(Object key) |
V |
removeKey(K key)
Remove an entry from the map at the specified
key. |
V |
updateValue(K key,
Function0<? extends V> factory,
Function<? super V,? extends V> function)
Looks up the value associated with
key, applies the function to it, and replaces the value. |
<P> V |
updateValueWith(K key,
Function0<? extends V> factory,
Function2<? super V,? super P,? extends V> function,
P parameter)
Same as
MutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function. |
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, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, equals, flatCollect, forEach, forEachWith, forEachWithIndex, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, groupByUniqueKey, hashCode, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, iterator, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, size, 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, toString, zip, zipWithIndexgetClass, hashCode, notify, notifyAll, wait, wait, waitaggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collectValues, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, newEmpty, partition, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, toImmutable, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexequals, hashCode, keysView, toString, valuesViewallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collect, collectBoolean, collectBoolean, collectByte, collectByte, collectChar, collectChar, collectDouble, collectDouble, collectFloat, collectFloat, collectIf, collectIf, collectInt, collectInt, collectLong, collectLong, collectShort, collectShort, collectWith, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, partitionWith, reject, rejectWith, select, selectWith, size, 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, zipWithIndexforEach, forEachWith, forEachWithIndexforEach, iterator, spliteratorcompute, computeIfAbsent, computeIfPresent, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, valuespublic V get(Object key)
get in interface Map<K,V>get in interface MapIterable<K,V>Map.get(Object)public V getIfAbsent(K key, Function0<? extends V> function)
MapIterablegetIfAbsent in interface MapIterable<K,V>public V getIfAbsentValue(K key, V value)
MapIterablevalue.getIfAbsentValue in interface MapIterable<K,V>public <P> V getIfAbsentWith(K key, Function<? super P,? extends V> function, P parameter)
MapIterablegetIfAbsentWith in interface MapIterable<K,V>public <A> A ifPresentApply(K key, Function<? super V,? extends A> function)
MapIterableifPresentApply in interface MapIterable<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in interface MapIterable<K,V>Map.containsKey(Object)public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in interface MapIterable<K,V>Map.containsValue(Object)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>public void forEachKey(Procedure<? super K> procedure)
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 MapIterable<K,V>public void forEachKeyValue(Procedure2<? super K,? super V> procedure2)
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");
forEachKeyValue in interface MapIterable<K,V>public Pair<K,V> detect(Predicate2<? super K,? super V> predicate)
MapIterable
e.g.
peopleByCity.detect(new Predicate2<City, Person>()
{
public boolean accept(City city, Person person)
{
return city.getName().equals("Anytown") && person.getLastName().equals("Smith");
}
});
detect in interface MapIterable<K,V>public V getIfAbsentPut(K key, Function0<? extends V> function)
MutableMapIterablegetIfAbsentPut in interface MutableMapIterable<K,V>public V getIfAbsentPut(K key, V value)
MutableMapIterablegetIfAbsentPut in interface MutableMapIterable<K,V>public V getIfAbsentPutWithKey(K key, Function<? super K,? extends V> function)
MutableMapIterablegetIfAbsentPutWithKey in interface MutableMapIterable<K,V>public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
MutableMapIterablegetIfAbsentPutWith in interface MutableMapIterable<K,V>public V removeKey(K key)
MutableMapIterablekey.removeKey in interface MutableMapIterable<K,V>Map.remove(Object)public V add(Pair<K,V> keyValuePair)
MutableMapIterableadd in interface MutableMapIterable<K,V>Map.put(Object, Object)public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
MutableMapIterablekey, applies the function to it, and replaces the value. If there
is no value associated with key, starts it off with a value supplied by factory.updateValue in interface MutableMapIterable<K,V>public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)
MutableMapIterableMutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function.updateValueWith in interface MutableMapIterable<K,V>public RichIterable<Pair<K,V>> keyValuesView()
MapIterablekeyValuesView in interface MapIterable<K,V>Copyright © 2004–2016. All rights reserved.