@NotThreadSafe public class UnifiedMapWithHashingStrategy<K,V> extends AbstractMutableMap<K,V> implements java.io.Externalizable, BatchIterable<V>
| Modifier and Type | Class and Description |
|---|---|
protected class |
UnifiedMapWithHashingStrategy.EntrySet |
protected class |
UnifiedMapWithHashingStrategy.EntrySetIterator |
protected class |
UnifiedMapWithHashingStrategy.KeySet |
protected class |
UnifiedMapWithHashingStrategy.KeySetIterator |
protected class |
UnifiedMapWithHashingStrategy.PositionalIterator<T> |
protected class |
UnifiedMapWithHashingStrategy.ValuesCollection |
protected class |
UnifiedMapWithHashingStrategy.ValuesIterator |
protected static class |
UnifiedMapWithHashingStrategy.WeakBoundEntry<K,V> |
AbstractMutableMap.ValuesCollectionCommon<V>| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.Object |
CHAINED_KEY |
protected static int |
DEFAULT_INITIAL_CAPACITY |
protected static float |
DEFAULT_LOAD_FACTOR |
protected float |
loadFactor |
protected int |
maxSize |
protected static java.lang.Object |
NULL_KEY |
protected int |
occupied |
protected java.lang.Object[] |
table |
| Constructor and Description |
|---|
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(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy) |
UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int initialCapacity) |
UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int initialCapacity,
float loadFactor) |
UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
java.util.Map<? extends K,? extends V> map) |
UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
com.gs.collections.api.tuple.Pair<K,V>... pairs) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
allocate(int capacity) |
protected void |
allocateTable(int sizeToAllocate) |
void |
batchForEach(com.gs.collections.api.block.procedure.Procedure<? super V> procedure,
int sectionIndex,
int sectionCount) |
void |
clear() |
UnifiedMapWithHashingStrategy<K,V> |
clone()
Returns a string representation of this map.
|
<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
collection to this. |
protected void |
computeMaxSize(int capacity) |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
protected void |
copyMap(UnifiedMapWithHashingStrategy<K,V> unifiedMap) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object object)
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 |
getCollidingBuckets() |
V |
getIfAbsentPut(K key,
com.gs.collections.api.block.function.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,
com.gs.collections.api.block.function.Function<? super P,? extends V> function,
P parameter)
Get and return the value in the Map at the specified key.
|
int |
getMapMemoryUsedInWords()
Returns the number of JVM words that is used by this map.
|
int |
hashCode()
Follows the same general contract as
Map.hashCode(). |
com.gs.collections.api.block.HashingStrategy<? super K> |
hashingStrategy() |
protected int |
index(K key) |
protected int |
init(int initialCapacity) |
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
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.
|
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.
|
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int size) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
int size,
float loadFactor) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
java.util.Map<? extends K,? extends V> map) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMap(UnifiedMapWithHashingStrategy<K,V> map) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newMapWith(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
com.gs.collections.api.tuple.Pair<K,V>... pairs) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
K key,
V value) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
K key1,
V value1,
K key2,
V value2) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
static <K,V> UnifiedMapWithHashingStrategy<K,V> |
newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy,
K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> map) |
void |
readExternal(java.io.ObjectInput in) |
protected void |
rehash(int newCapacity) |
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 MapIterable.
|
V |
updateValue(K key,
com.gs.collections.api.block.function.Function0<? extends V> factory,
com.gs.collections.api.block.function.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,
com.gs.collections.api.block.function.Function0<? extends V> factory,
com.gs.collections.api.block.function.Function2<? super V,? super P,? extends V> function,
P parameter)
Same as
MutableMap.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function. |
java.util.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) |
void |
writeExternal(java.io.ObjectOutput out) |
add, aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, detect, flatCollect, flip, flipUniqueValues, getIfAbsentPutWithKey, groupBy, groupByEach, groupByUniqueKey, iterator, keysView, keyValuesView, partition, partitionWith, reject, reject, select, select, selectInstancesOf, selectWith, valuesView, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexallSatisfy, 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, flatCollect, forEach, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, groupBy, groupByEach, ifPresentApply, injectInto, injectInto, injectInto, injectInto, injectInto, isAbsent, keyAndValueEquals, keyAndValueHashCode, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexfinalize, 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, flatCollect, getFirst, getLast, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexprotected static final java.lang.Object NULL_KEY
protected static final java.lang.Object CHAINED_KEY
protected static final float DEFAULT_LOAD_FACTOR
protected static final int DEFAULT_INITIAL_CAPACITY
protected transient java.lang.Object[] table
protected transient int occupied
protected float loadFactor
protected int maxSize
@Deprecated public UnifiedMapWithHashingStrategy()
public UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy)
public UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int initialCapacity)
public UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int initialCapacity, float loadFactor)
public UnifiedMapWithHashingStrategy(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, java.util.Map<? extends K,? extends V> map)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int size)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, int size, float loadFactor)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMap(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, java.util.Map<? extends K,? extends V> map)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMap(UnifiedMapWithHashingStrategy<K,V> map)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newMapWith(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, com.gs.collections.api.tuple.Pair<K,V>... pairs)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, K key, V value)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3)
public static <K,V> UnifiedMapWithHashingStrategy<K,V> newWithKeysValues(com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy, K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public UnifiedMapWithHashingStrategy<K,V> withKeysValues(K key, V value)
public UnifiedMapWithHashingStrategy<K,V> withKeysValues(K key1, V value1, K key2, V value2)
public UnifiedMapWithHashingStrategy<K,V> withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)
public UnifiedMapWithHashingStrategy<K,V> withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public com.gs.collections.api.block.HashingStrategy<? super K> hashingStrategy()
public UnifiedMapWithHashingStrategy<K,V> clone()
AbstractMutableMapThis implementation creates an empty string buffer, appends a left brace, and iterates over the map's entrySet view, appending the string representation of each map.entry in turn. After appending each entry except the last, the string ", " is appended. Finally a right brace is appended. A string is obtained from the stringbuffer, and returned.
public com.gs.collections.api.map.MutableMap<K,V> newEmpty()
com.gs.collections.api.map.MutableMappublic com.gs.collections.api.map.MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>protected int init(int initialCapacity)
protected int allocate(int capacity)
protected void allocateTable(int sizeToAllocate)
protected void computeMaxSize(int capacity)
protected final int index(K key)
public V updateValue(K key, com.gs.collections.api.block.function.Function0<? extends V> factory, com.gs.collections.api.block.function.Function<? super V,? extends V> function)
com.gs.collections.api.map.MutableMapkey, 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 com.gs.collections.api.map.MutableMap<K,V>updateValue in class AbstractMutableMap<K,V>public <P> V updateValueWith(K key, com.gs.collections.api.block.function.Function0<? extends V> factory, com.gs.collections.api.block.function.Function2<? super V,? super P,? extends V> function, P parameter)
com.gs.collections.api.map.MutableMapMutableMap.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function.updateValueWith in interface com.gs.collections.api.map.MutableMap<K,V>updateValueWith in class AbstractMutableMap<K,V>public V getIfAbsentPut(K key, com.gs.collections.api.block.function.Function0<? extends V> function)
com.gs.collections.api.map.MutableMapgetIfAbsentPut in interface com.gs.collections.api.map.MutableMap<K,V>getIfAbsentPut in class AbstractMutableMap<K,V>public V getIfAbsentPut(K key, V value)
com.gs.collections.api.map.MutableMapgetIfAbsentPut in interface com.gs.collections.api.map.MutableMap<K,V>getIfAbsentPut in class AbstractMutableMap<K,V>public <P> V getIfAbsentPutWith(K key, com.gs.collections.api.block.function.Function<? super P,? extends V> function, P parameter)
com.gs.collections.api.map.MutableMapgetIfAbsentPutWith in interface com.gs.collections.api.map.MutableMap<K,V>getIfAbsentPutWith in class AbstractMutableMap<K,V>public int getCollidingBuckets()
public int getMapMemoryUsedInWords()
protected void rehash(int newCapacity)
public V get(java.lang.Object key)
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
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 <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.MutableMapcollection 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 it's value replaced by that in map.public V removeKey(K key)
com.gs.collections.api.map.MutableMapkey.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 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 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 boolean isEmpty()
com.gs.collections.api.RichIterableprotected void copyMap(UnifiedMapWithHashingStrategy<K,V> unifiedMap)
public int size()
com.gs.collections.api.RichIterablepublic boolean equals(java.lang.Object object)
com.gs.collections.api.map.MapIterableMap.equals(Object).public int hashCode()
com.gs.collections.api.map.MapIterableMap.hashCode().public java.lang.String toString()
com.gs.collections.api.map.MapIterableString.valueOf(Object).public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super V> objectIntProcedure)
com.gs.collections.api.InternalIterablee.g. 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.InternalIterablee.g. 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> toImmutable()
com.gs.collections.api.map.MutableMaptoImmutable in interface com.gs.collections.api.map.MutableMap<K,V>toImmutable in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>