public class MapAdapter<K,V> extends AbstractMutableMap<K,V> implements java.io.Serializable
To create a new wrapper around an existing Map instance, use the adapt(Map) factory method.
AbstractMutableMap.ValuesCollectionCommon<V>| Modifier | Constructor and Description |
|---|---|
protected |
MapAdapter(java.util.Map<K,V> newDelegate) |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> com.gs.collections.api.map.MutableMap<K,V> |
adapt(java.util.Map<K,V> map) |
void |
clear() |
com.gs.collections.api.map.MutableMap<K,V> |
clone() |
<E> com.gs.collections.api.map.MutableMap<K,V> |
collectKeysAndValues(java.lang.Iterable<E> iterable,
com.gs.collections.api.block.function.Function<? super E,? extends K> keyFunction,
com.gs.collections.api.block.function.Function<? super E,? extends V> valueFunction)
Adds all the entries derived from
iterable to this. |
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 |
forEachKeyValue(com.gs.collections.api.block.procedure.Procedure2<? super K,? super V> procedure)
Calls the
procedure with each key-value pair of the map. |
V |
get(java.lang.Object key) |
int |
hashCode()
Follows the same general contract as
Map.hashCode(). |
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
java.util.Iterator<V> |
iterator() |
java.util.Set<K> |
keySet() |
com.gs.collections.api.map.MutableMap<K,V> |
newEmpty()
Creates a new instance of the same type, using the default capacity and growth parameters.
|
<K,V> com.gs.collections.api.map.MutableMap<K,V> |
newEmpty(int capacity)
Creates a new instance of the same type, using the given capacity and the default growth parameters.
|
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> map) |
V |
remove(java.lang.Object key) |
V |
removeKey(K key)
Remove an entry from the map at the specified
key. |
int |
size()
Returns the number of items in this iterable.
|
com.gs.collections.api.map.ImmutableMap<K,V> |
toImmutable()
Returns an immutable copy of this map.
|
java.lang.String |
toString()
Returns a string representation of this collection.
|
java.util.Collection<V> |
values() |
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexadd, aggregateBy, aggregateInPlaceBy, collect, detect, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, groupByUniqueKey, keysView, keyValuesView, updateValue, updateValueWith, valuesViewallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectWith, detectWithIfNone, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, 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, 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, zipWithIndexfinalize, getClass, notify, notifyAll, wait, wait, waitaggregateBy, aggregateInPlaceBy, collect, flipUniqueValues, groupByUniqueKeyadd, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, updateValue, updateValueWithdetect, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, valuesViewallSatisfy, 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, 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 static <K,V> com.gs.collections.api.map.MutableMap<K,V> adapt(java.util.Map<K,V> map)
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 <K,V> com.gs.collections.api.map.MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>public int size()
com.gs.collections.api.RichIterablepublic boolean isEmpty()
com.gs.collections.api.RichIterablepublic java.util.Iterator<V> iterator()
iterator in interface java.lang.Iterable<V>iterator in class AbstractMutableMapIterable<K,V>public com.gs.collections.api.map.MutableMap<K,V> newEmpty()
com.gs.collections.api.map.MutableMapIterablepublic 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 V get(java.lang.Object key)
public <E> com.gs.collections.api.map.MutableMap<K,V> collectKeysAndValues(java.lang.Iterable<E> iterable, com.gs.collections.api.block.function.Function<? super E,? extends K> keyFunction, com.gs.collections.api.block.function.Function<? super E,? extends V> valueFunction)
com.gs.collections.api.map.MutableMapiterable to this. The key and value for each entry
is determined by applying the keyFunction and valueFunction to each item in
collection. Any entry in map that has the same key as an entry in this
will have its value replaced by that in map.public V removeKey(K key)
com.gs.collections.api.map.MutableMapIterablekey.public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
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 com.gs.collections.api.map.ImmutableMap<K,V> toImmutable()
com.gs.collections.api.map.MutableMapIterabletoImmutable in interface com.gs.collections.api.map.MapIterable<K,V>toImmutable in interface com.gs.collections.api.map.MutableMapIterable<K,V>toImmutable in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>