public class UnifiedMap<K,V> extends AbstractMutableMap<K,V> implements Externalizable, BatchIterable<V>
The final result is a Map implementation that's leaner than java.util.HashMap and faster than Trove's THashMap. The best of both approaches unified together, and thus the name UnifiedMap.
| Constructor and Description |
|---|
UnifiedMap() |
UnifiedMap(int initialCapacity) |
UnifiedMap(int initialCapacity,
float loadFactor) |
UnifiedMap(Map<? extends K,? extends V> map) |
UnifiedMap(Pair<K,V>... pairs) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allSatisfy(Predicate<? super V> predicate) |
<P> boolean |
allSatisfyWith(Predicate2<? super V,? super P> predicate,
P parameter) |
boolean |
anySatisfy(Predicate<? super V> predicate) |
<P> boolean |
anySatisfyWith(Predicate2<? super V,? super P> predicate,
P parameter) |
void |
batchForEach(Procedure<? super V> procedure,
int sectionIndex,
int sectionCount) |
void |
clear() |
UnifiedMap<K,V> |
clone() |
<E> MutableMap<K,V> |
collectKeysAndValues(Iterable<E> iterable,
Function<? super E,? extends K> keyFunction,
Function<? super E,? extends V> valueFunction) |
<R> MutableMap<K,R> |
collectValues(Function2<? super K,? super V,? extends R> function) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
V |
detect(Predicate<? super V> predicate) |
Pair<K,V> |
detect(Predicate2<? super K,? super V> predicate) |
V |
detectIfNone(Predicate<? super V> predicate,
Function0<? extends V> function) |
Optional<V> |
detectOptional(Predicate<? super V> predicate) |
Optional<Pair<K,V>> |
detectOptional(Predicate2<? super K,? super V> predicate) |
<P> V |
detectWith(Predicate2<? super V,? super P> predicate,
P parameter) |
<P> V |
detectWithIfNone(Predicate2<? super V,? super P> predicate,
P parameter,
Function0<? extends V> function) |
<P> Optional<V> |
detectWithOptional(Predicate2<? super V,? super P> predicate,
P parameter) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object object) |
void |
forEachKey(Procedure<? super K> procedure) |
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure) |
void |
forEachValue(Procedure<? super V> procedure) |
<P> void |
forEachWith(Procedure2<? super V,? super P> procedure,
P parameter) |
void |
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) |
V |
get(Object key) |
int |
getBatchCount(int batchSize) |
int |
getCollidingBuckets() |
V |
getFirst() |
V |
getIfAbsentPut(K key,
Function0<? extends V> function) |
V |
getIfAbsentPut(K key,
V value) |
<P> V |
getIfAbsentPutWith(K key,
Function<? super P,? extends V> function,
P parameter) |
int |
getMapMemoryUsedInWords()
Returns the number of JVM words that is used by this map.
|
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
MutableMap<K,V> |
newEmpty() |
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> UnifiedMap<K,V> |
newMap() |
static <K,V> UnifiedMap<K,V> |
newMap(int size) |
static <K,V> UnifiedMap<K,V> |
newMap(int size,
float loadFactor) |
static <K,V> UnifiedMap<K,V> |
newMap(Map<? extends K,? extends V> map) |
static <K,V> UnifiedMap<K,V> |
newMapWith(Iterable<Pair<K,V>> inputIterable) |
static <K,V> UnifiedMap<K,V> |
newMapWith(Pair<K,V>... pairs) |
static <K,V> UnifiedMap<K,V> |
newWithKeysValues(K key,
V value) |
static <K,V> UnifiedMap<K,V> |
newWithKeysValues(K key1,
V value1,
K key2,
V value2) |
static <K,V> UnifiedMap<K,V> |
newWithKeysValues(K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
static <K,V> UnifiedMap<K,V> |
newWithKeysValues(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
boolean |
noneSatisfy(Predicate<? super V> predicate) |
<P> boolean |
noneSatisfyWith(Predicate2<? super V,? super P> predicate,
P parameter) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
void |
readExternal(ObjectInput in) |
V |
remove(Object key) |
boolean |
removeIf(Predicate2<? super K,? super V> predicate) |
V |
removeKey(K key) |
int |
size() |
ImmutableMap<K,V> |
toImmutable() |
String |
toString()
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
boolean |
trimToSize() |
V |
updateValue(K key,
Function0<? extends V> factory,
Function<? super V,? extends V> function) |
<P> V |
updateValueWith(K key,
Function0<? extends V> factory,
Function2<? super V,? super P,? extends V> function,
P parameter) |
Collection<V> |
values() |
UnifiedMap<K,V> |
withKeysValues(K key,
V value) |
UnifiedMap<K,V> |
withKeysValues(K key1,
V value1,
K key2,
V value2) |
UnifiedMap<K,V> |
withKeysValues(K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
UnifiedMap<K,V> |
withKeysValues(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
void |
writeExternal(ObjectOutput out) |
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, zipWithIndexaggregateBy, collect, countBy, countByEach, countByWith, flipUniqueValues, getIfAbsentPutWithKey, iterator, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesViewasLazy, chunk, contains, each, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, getOrDefault, ifPresentApply, toArray, toArrayappendString, appendString, collect, collectIf, 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, zipWithIndexforEachaggregateBy, aggregateBy, aggregateInPlaceBy, collect, flatCollectWith, flipUniqueValues, withMap, withMapIterableadd, countBy, countByEach, countByWith, getIfAbsentPutWithKey, getOrDefault, putAllMapIterable, putPair, removeAllKeys, sumByDouble, sumByFloat, sumByInt, sumByLongcompute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAllgetIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewaggregateBy, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEachpublic UnifiedMap()
public UnifiedMap(int initialCapacity)
public UnifiedMap(int initialCapacity,
float loadFactor)
public static <K,V> UnifiedMap<K,V> newMap()
public static <K,V> UnifiedMap<K,V> newMap(int size)
public static <K,V> UnifiedMap<K,V> newMap(int size, float loadFactor)
public static <K,V> UnifiedMap<K,V> newMap(Map<? extends K,? extends V> map)
public static <K,V> UnifiedMap<K,V> newMapWith(Pair<K,V>... pairs)
public static <K,V> UnifiedMap<K,V> newMapWith(Iterable<Pair<K,V>> inputIterable)
public static <K,V> UnifiedMap<K,V> newWithKeysValues(K key, V value)
public static <K,V> UnifiedMap<K,V> newWithKeysValues(K key1, V value1, K key2, V value2)
public static <K,V> UnifiedMap<K,V> newWithKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)
public static <K,V> UnifiedMap<K,V> newWithKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public UnifiedMap<K,V> withKeysValues(K key, V value)
public UnifiedMap<K,V> withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)
public UnifiedMap<K,V> withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public UnifiedMap<K,V> clone()
clone in interface MutableMap<K,V>clone in class AbstractMutableMap<K,V>public MutableMap<K,V> newEmpty()
newEmpty in interface MutableMap<K,V>newEmpty in interface MutableMapIterable<K,V>public MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
updateValue in interface MutableMapIterable<K,V>updateValue in class AbstractMutableMapIterable<K,V>public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)
updateValueWith in interface MutableMapIterable<K,V>updateValueWith in class AbstractMutableMapIterable<K,V>public V getIfAbsentPut(K key, Function0<? extends V> function)
getIfAbsentPut in interface MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public V getIfAbsentPut(K key, V value)
getIfAbsentPut in interface MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
getIfAbsentPutWith in interface MutableMapIterable<K,V>getIfAbsentPutWith in class AbstractMutableMapIterable<K,V>public int getCollidingBuckets()
public int getMapMemoryUsedInWords()
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in interface MapIterable<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in interface MapIterable<K,V>public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
forEachKeyValue in interface MapIterable<K,V>public V getFirst()
getFirst in interface RichIterable<V>getFirst in class AbstractMapIterable<K,V>public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E,? extends K> keyFunction, Function<? super E,? extends V> valueFunction)
collectKeysAndValues in interface MutableMap<K,V>public boolean removeIf(Predicate2<? super K,? super V> predicate)
removeIf in interface MutableMapIterable<K,V>public int getBatchCount(int batchSize)
getBatchCount in interface BatchIterable<V>public void batchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount)
batchForEach in interface BatchIterable<V>public void forEachKey(Procedure<? super K> procedure)
forEachKey in interface MapIterable<K,V>forEachKey in class AbstractMapIterable<K,V>public void forEachValue(Procedure<? super V> procedure)
forEachValue in interface MapIterable<K,V>forEachValue in class AbstractMapIterable<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>isEmpty in interface RichIterable<V>isEmpty in class AbstractRichIterable<V>public int size()
size in interface Map<K,V>size in interface RichIterable<V>size in interface BatchIterable<V>public boolean equals(Object object)
public int hashCode()
public String toString()
AbstractRichIterable
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());
toString in interface MapIterable<K,V>toString in interface RichIterable<V>toString in class AbstractRichIterable<V>AbstractCollection.toString()public boolean trimToSize()
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)
forEachWithIndex in interface InternalIterable<V>forEachWithIndex in class AbstractMapIterable<K,V>public <P> void forEachWith(Procedure2<? super V,? super P> procedure, P parameter)
forEachWith in interface InternalIterable<V>forEachWith in class AbstractMapIterable<K,V>public <R> MutableMap<K,R> collectValues(Function2<? super K,? super V,? extends R> function)
collectValues in interface MapIterable<K,V>collectValues in interface MutableMap<K,V>collectValues in interface MutableMapIterable<K,V>collectValues in interface UnsortedMapIterable<K,V>collectValues in class AbstractMutableMap<K,V>public Pair<K,V> detect(Predicate2<? super K,? super V> predicate)
detect in interface MapIterable<K,V>detect in class AbstractMutableMapIterable<K,V>public V detect(Predicate<? super V> predicate)
detect in interface RichIterable<V>detect in class AbstractMapIterable<K,V>public <P> V detectWith(Predicate2<? super V,? super P> predicate, P parameter)
detectWith in interface RichIterable<V>detectWith in class AbstractMapIterable<K,V>public Optional<Pair<K,V>> detectOptional(Predicate2<? super K,? super V> predicate)
detectOptional in interface MapIterable<K,V>detectOptional in class AbstractMutableMapIterable<K,V>public Optional<V> detectOptional(Predicate<? super V> predicate)
detectOptional in interface RichIterable<V>detectOptional in class AbstractMapIterable<K,V>public <P> Optional<V> detectWithOptional(Predicate2<? super V,? super P> predicate, P parameter)
detectWithOptional in interface RichIterable<V>detectWithOptional in class AbstractMapIterable<K,V>public V detectIfNone(Predicate<? super V> predicate, Function0<? extends V> function)
detectIfNone in interface RichIterable<V>detectIfNone in class AbstractMapIterable<K,V>public <P> V detectWithIfNone(Predicate2<? super V,? super P> predicate, P parameter, Function0<? extends V> function)
detectWithIfNone in interface RichIterable<V>detectWithIfNone in class AbstractMapIterable<K,V>public boolean anySatisfy(Predicate<? super V> predicate)
anySatisfy in interface RichIterable<V>anySatisfy in class AbstractMapIterable<K,V>public <P> boolean anySatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
anySatisfyWith in interface RichIterable<V>anySatisfyWith in class AbstractMapIterable<K,V>public boolean allSatisfy(Predicate<? super V> predicate)
allSatisfy in interface RichIterable<V>allSatisfy in class AbstractMapIterable<K,V>public <P> boolean allSatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
allSatisfyWith in interface RichIterable<V>allSatisfyWith in class AbstractMapIterable<K,V>public boolean noneSatisfy(Predicate<? super V> predicate)
noneSatisfy in interface RichIterable<V>noneSatisfy in class AbstractMapIterable<K,V>public <P> boolean noneSatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
noneSatisfyWith in interface RichIterable<V>noneSatisfyWith in class AbstractMapIterable<K,V>public ImmutableMap<K,V> toImmutable()
toImmutable in interface MapIterable<K,V>toImmutable in interface MutableMapIterable<K,V>toImmutable in interface UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>Copyright © 2004–2022. All rights reserved.