public final class Maps extends Object
Modifier and Type | Method and Description |
---|---|
static <K,V> ConcurrentMap<K,V> |
createConcurrentMap()
Create and return a new instance of ConcurrentMap.
|
static <K,V> ConcurrentMap<K,V> |
createConcurrentMap(int initialCapacity)
Create and return a new instance of ConcurrentMap with the specified initial capacity.
|
static <K,V> ConcurrentMap<K,V> |
createConcurrentMap(int initialCapacity,
float loadFactor)
Create and return a new instance of ConcurrentMap with the specified initial capacity
and load factor.
|
static <K,V> ConcurrentMap<K,V> |
createConcurrentMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
Create and return a new instance of ConcurrentMap with the specified initial capacity,
load factor, and concurrency level.
|
static <K,V> ConcurrentMap<K,V> |
createConcurrentMap(Map<? extends K,? extends V> map)
Create and return a new instance of ConcurrentMap with the same mappings as the
specified map.
|
static <K,V> ConcurrentSkipListMap<K,V> |
createConcurrentSkipListMap()
Create and return a new instance of ConcurrentSkipListMap sorted according
to the natural ordering of its keys.
|
static <K,V> ConcurrentSkipListMap<K,V> |
createConcurrentSkipListMap(Comparator<? super K> comparator)
Create and return a new instance of ConcurrentSkipListMap sorted according
to the specified comparator.
|
static <K,V> ConcurrentSkipListMap<K,V> |
createConcurrentSkipListMap(Map<? extends K,? extends V> map)
Create and return a new instance of ConcurrentSkipListMap containing the
same mappings as the specified map and sorted according to the natural ordering of
its keys.
|
static <K,V> ConcurrentSkipListMap<K,V> |
createConcurrentSkipListMap(SortedMap<K,? extends V> sortedMap)
Create and return a new instance of ConcurrentSkipListMap containing the
same mappings and using the same ordering as the specified sorted map.
|
static <V> ConcurrentMap<Long,V> |
createLongNonBlockingMap()
Create and return a new non-blocking implementation of ConcurrentMap with
Long s as keys. |
static <V> ConcurrentMap<Long,V> |
createLongNonBlockingMap(boolean optimizeForSpace)
Create and return a new non-blocking implementation of ConcurrentMap with
Long s as keys. |
static <V> ConcurrentMap<Long,V> |
createLongNonBlockingMap(int initialCapacity)
Create and return a new non-blocking implementation of ConcurrentMap with
the specified initial capacity and
Long s as keys. |
static <V> ConcurrentMap<Long,V> |
createLongNonBlockingMap(int initialCapacity,
boolean optimizeForSpace)
Create and return a new non-blocking implementation of ConcurrentMap with
the specified initial capacity and
Long s as keys. |
static <K,V> Map<K,V> |
createMap()
Create and return a new instance of Map.
|
static <K,V> Map<K,V> |
createMap(int initialCapacity)
Create and return a new instance of Map with the specified initial capacity.
|
static <K,V> Map<K,V> |
createMap(int initialCapacity,
float loadFactor)
Create and return a new instance of Map with the specified initial capacity
and load factor.
|
static <K,V> Map<K,V> |
createMap(Map<? extends K,? extends V> map)
Create and return a new instance of Map with the same mappings as the
specified map.
|
static <K,V> NavigableMap<K,V> |
createNavigableMap()
Create and return a new instance of NavigableMap using the natural ordering of its keys.
|
static <K,V> NavigableMap<K,V> |
createNavigableMap(Comparator<? super K> comparator)
Create and return a new instance of NavigableMap ordered according to the specified comparator.
|
static <K,V> NavigableMap<K,V> |
createNavigableMap(Map<? extends K,? extends V> map)
Create and return a new instance of NavigableMap containing the same mappings as the specified
map ordered according to the natural ordering of its keys.
|
static <K,V> NavigableMap<K,V> |
createNavigableMap(NavigableMap<K,? extends V> navigableMap)
Create and return a new instance of NavigableMap containing the same mappings and the same
ordering as the specified navigable map.
|
static <K,V> ConcurrentMap<K,V> |
createNonBlockingMap()
Create and return a new non-blocking implementation of ConcurrentMap.
|
static <K,V> ConcurrentMap<K,V> |
createNonBlockingMap(int initialCapacity)
Create and return a new non-blocking implementation of ConcurrentMap with the
specified initial capacity.
|
static <K,V> SortedMap<K,V> |
createSortedMap()
Create and return a new instance of SortedMap using the natural ordering of its keys.
|
static <K,V> SortedMap<K,V> |
createSortedMap(Comparator<? super K> comparator)
Create and return a new instance of SortedMap ordered according to the specified comparator.
|
static <K,V> SortedMap<K,V> |
createSortedMap(Map<? extends K,? extends V> map)
Create and return a new instance of SortedMap containing the same mappings as the specified
map ordered according to the natural ordering of its keys.
|
static <K,V> SortedMap<K,V> |
createSortedMap(SortedMap<K,? extends V> sortedMap)
Create and return a new instance of SortedMap containing the same mappings and the same
ordering as the specified sorted map.
|
static <K,V> Map<K,V> |
createSynchronizedMap()
Create and return a new synchronized (thread-safe) instance of Map.
|
static <K,V> Map<K,V> |
createSynchronizedMap(int initialCapacity)
Create and return a new synchronized (thread-safe) instance of Map with
the specified initial capacity.
|
static <K,V> Map<K,V> |
createSynchronizedMap(int initialCapacity,
float loadFactor)
Create and return a new synchronized (thread-safe) instance of Map with
the specified initial capacity and load factor.
|
static <K,V> Map<K,V> |
createSynchronizedMap(Map<? extends K,? extends V> map)
Create and return a new synchronized (thread-safe) instance of Map with
the same mappings as the specified map.
|
static <K,V> Map<K,V> |
emptyMap()
Create and return a new empty map.
|
static <K,V> Map<K,V> |
immutableMap(Map<? extends K,? extends V> map)
Create and return an immutable map containing the same mappings as the specified map.
|
static <K,V> SortedMap<K,V> |
immutableSortedMap(SortedMap<K,? extends V> sortedMap)
Create and return an immutable sorted map containing the same mappings and the same
ordering as the specified sorted map.
|
static <K,V> Map<K,V> |
unmodifiableMap(Map<? extends K,? extends V> map)
Create and return a new unmodifiable view of the specified map.
|
static <K,V> SortedMap<K,V> |
unmodifiableSortedMap(SortedMap<K,? extends V> sortedMap)
Create and return a new unmodifiable view of the specified sorted map.
|
public static <K,V> Map<K,V> emptyMap()
Collections.emptyMap()
.K
- key typeV
- value typepublic static <K,V> Map<K,V> createMap()
K
- key typeV
- value typepublic static <K,V> Map<K,V> createMap(int initialCapacity)
K
- key typeV
- value typeinitialCapacity
- initial capacitypublic static <K,V> Map<K,V> createMap(int initialCapacity, float loadFactor)
K
- key typeV
- value typeinitialCapacity
- initial capacityloadFactor
- load factorpublic static <K,V> Map<K,V> createMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy mappings frompublic static <K,V> Map<K,V> createSynchronizedMap()
Map m = Maps.newSynchronizedMap(); ... Set s = m.keySet(); // Needn't be in synchronized block ... synchronized(m) // Synchronizing on m, not s! { Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
K
- key typeV
- value typepublic static <K,V> Map<K,V> createSynchronizedMap(int initialCapacity)
Map m = Maps.newSynchronizedMap(10); ... Set s = m.keySet(); // Needn't be in synchronized block ... synchronized(m) // Synchronizing on m, not s! { Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
K
- key typeV
- value typeinitialCapacity
- initial capacitypublic static <K,V> Map<K,V> createSynchronizedMap(int initialCapacity, float loadFactor)
Map m = Maps.newSynchronizedMap(10, 0.80); ... Set s = m.keySet(); // Needn't be in synchronized block ... synchronized(m) // Synchronizing on m, not s! { Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
K
- key typeV
- value typeinitialCapacity
- initial capacityloadFactor
- load factorpublic static <K,V> Map<K,V> createSynchronizedMap(Map<? extends K,? extends V> map)
Map m = Maps.newSynchronizedMap(map); ... Set s = m.keySet(); // Needn't be in synchronized block ... synchronized(m) // Synchronizing on m, not s! { Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) { foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
K
- key typeV
- value typemap
- map to copy mappings frompublic static <K,V> ConcurrentMap<K,V> createConcurrentMap()
K
- key typeV
- value typepublic static <K,V> ConcurrentMap<K,V> createConcurrentMap(int initialCapacity)
K
- key typeV
- value typeinitialCapacity
- initial capacitypublic static <K,V> ConcurrentMap<K,V> createConcurrentMap(int initialCapacity, float loadFactor)
K
- key typeV
- value typeinitialCapacity
- initial capacityloadFactor
- load factorpublic static <K,V> ConcurrentMap<K,V> createConcurrentMap(int initialCapacity, float loadFactor, int concurrencyLevel)
K
- key typeV
- value typeinitialCapacity
- initial capacityloadFactor
- load factorconcurrencyLevel
- concurrency levelpublic static <K,V> ConcurrentMap<K,V> createConcurrentMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy mappings from, must not be nullpublic static <K,V> ConcurrentMap<K,V> createNonBlockingMap()
K
- key typeV
- value typepublic static <K,V> ConcurrentMap<K,V> createNonBlockingMap(int initialCapacity)
K
- key typeV
- value typeinitialCapacity
- initial capacitypublic static <V> ConcurrentMap<Long,V> createLongNonBlockingMap()
Long
s as keys.V
- value typeLong
s as keyspublic static <V> ConcurrentMap<Long,V> createLongNonBlockingMap(boolean optimizeForSpace)
Long
s as keys.V
- value typeoptimizeForSpace
- true if the implementation should optimize for spaceLong
s as keyspublic static <V> ConcurrentMap<Long,V> createLongNonBlockingMap(int initialCapacity)
Long
s as keys.V
- value typeinitialCapacity
- initial capacityLong
s as keyspublic static <V> ConcurrentMap<Long,V> createLongNonBlockingMap(int initialCapacity, boolean optimizeForSpace)
Long
s as keys.V
- value typeinitialCapacity
- initial capacityoptimizeForSpace
- true if this implementation should optimize for spaceLong
s as keyspublic static <K,V> ConcurrentSkipListMap<K,V> createConcurrentSkipListMap()
K
- key typeV
- value typepublic static <K,V> ConcurrentSkipListMap<K,V> createConcurrentSkipListMap(Comparator<? super K> comparator)
K
- key typeV
- value typecomparator
- comparator that will be used to order this map, or
null
to use the natural ordering of its keyspublic static <K,V> ConcurrentSkipListMap<K,V> createConcurrentSkipListMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy mappings from, must not be nullpublic static <K,V> ConcurrentSkipListMap<K,V> createConcurrentSkipListMap(SortedMap<K,? extends V> sortedMap)
K
- key typeV
- value typesortedMap
- sorted map to copy mappings and ordering from, must not be nullpublic static <K,V> SortedMap<K,V> createSortedMap()
K
- key typeV
- value typepublic static <K,V> SortedMap<K,V> createSortedMap(Comparator<? super K> comparator)
K
- key typeV
- value typecomparator
- comparator used to order this map, or null
to use the
natural ordering of its keyspublic static <K,V> SortedMap<K,V> createSortedMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy mappings from, must not be nullpublic static <K,V> SortedMap<K,V> createSortedMap(SortedMap<K,? extends V> sortedMap)
K
- key typeV
- value typesortedMap
- sorted map to copy mappings and comparator from, must not be nullpublic static <K,V> NavigableMap<K,V> createNavigableMap()
K
- key typeV
- value typepublic static <K,V> NavigableMap<K,V> createNavigableMap(Comparator<? super K> comparator)
K
- key typeV
- value typecomparator
- comparator used to order this map, or null
to use the
natural ordering of its keyspublic static <K,V> NavigableMap<K,V> createNavigableMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy mappings from, must not be nullpublic static <K,V> NavigableMap<K,V> createNavigableMap(NavigableMap<K,? extends V> navigableMap)
K
- key typeV
- value typenavigableMap
- navigable map to copy mappings and comparator from, must not be nullpublic static <K,V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> map)
UnsupportedOperationException
.K
- key typeV
- value typemap
- map to view, must not be nullpublic static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K,? extends V> sortedMap)
subMap
,
headMap
, or tailMap
views, result in an
UnsupportedOperationException
.K
- key typeV
- value typesortedMap
- sorted map to view, must not be nullpublic static <K,V> Map<K,V> immutableMap(Map<? extends K,? extends V> map)
K
- key typeV
- value typemap
- map to copy, must not be nullpublic static <K,V> SortedMap<K,V> immutableSortedMap(SortedMap<K,? extends V> sortedMap)
K
- key typeV
- value typesortedMap
- sorted map to copy, must not be nullCopyright (c) 2008-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).