public final class CollectionHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Collection |
EMPTY_COLLECTION
Deprecated.
use
Collections.EMPTY_LIST or Collections.emptyList() instead |
static java.util.List |
EMPTY_LIST
Deprecated.
use
Collections.EMPTY_LIST or Collections.emptyList() instead |
static java.util.Map |
EMPTY_MAP
Deprecated.
use
Collections.EMPTY_MAP or Collections.emptyMap() instead |
static float |
LOAD_FACTOR |
static int |
MINIMUM_INITIAL_CAPACITY |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.ArrayList<T> |
arrayList(int anticipatedSize) |
static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> |
concurrentMap(int expectedNumberOfElements)
Create a properly sized
ConcurrentHashMap based on the given expected number of elements. |
static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> |
concurrentMap(int expectedNumberOfElements,
float loadFactor)
Create a properly sized
ConcurrentHashMap based on the given expected number of elements and an
explicit load factor |
static int |
determineProperSizing(int numberOfElements)
Determine the proper initial size for a new collection in order for it to hold the given a number of elements.
|
static int |
determineProperSizing(java.util.Map original)
Given a map, determine the proper initial size for a new Map to hold the same number of values.
|
static int |
determineProperSizing(java.util.Set original)
Given a set, determine the proper initial size for a new set to hold the same number of values.
|
static boolean |
isEmpty(java.util.Collection collection) |
static boolean |
isEmpty(java.util.Map map) |
static boolean |
isEmpty(java.lang.Object[] objects) |
static boolean |
isNotEmpty(java.util.Collection collection) |
static boolean |
isNotEmpty(java.util.Map map) |
static <X,Y> java.util.Map<X,Y> |
makeCopy(java.util.Map<X,Y> map) |
static <T> java.util.Set<T> |
makeCopy(java.util.Set<T> source) |
static <K,V> java.util.Map<K,V> |
mapOfSize(int size)
Build a properly sized map, especially handling load size and load factor to prevent immediate resizing.
|
public static final int MINIMUM_INITIAL_CAPACITY
public static final float LOAD_FACTOR
@Deprecated public static final java.util.List EMPTY_LIST
Collections.EMPTY_LIST
or Collections.emptyList()
instead@Deprecated public static final java.util.Collection EMPTY_COLLECTION
Collections.EMPTY_LIST
or Collections.emptyList()
instead@Deprecated public static final java.util.Map EMPTY_MAP
Collections.EMPTY_MAP
or Collections.emptyMap()
insteadpublic static <K,V> java.util.Map<K,V> mapOfSize(int size)
size
- The size to make the map.public static int determineProperSizing(java.util.Map original)
original
- The original mappublic static int determineProperSizing(java.util.Set original)
original
- The original setpublic static int determineProperSizing(int numberOfElements)
numberOfElements
- The number of elements to be stored.public static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> concurrentMap(int expectedNumberOfElements)
ConcurrentHashMap
based on the given expected number of elements.K
- The map key typeV
- The map value typeexpectedNumberOfElements
- The expected number of elements for the created mappublic static <K,V> java.util.concurrent.ConcurrentHashMap<K,V> concurrentMap(int expectedNumberOfElements, float loadFactor)
ConcurrentHashMap
based on the given expected number of elements and an
explicit load factorK
- The map key typeV
- The map value typeexpectedNumberOfElements
- The expected number of elements for the created maploadFactor
- The collection load factorpublic static <T> java.util.ArrayList<T> arrayList(int anticipatedSize)
public static <T> java.util.Set<T> makeCopy(java.util.Set<T> source)
public static boolean isEmpty(java.util.Collection collection)
public static boolean isEmpty(java.util.Map map)
public static boolean isNotEmpty(java.util.Collection collection)
public static boolean isNotEmpty(java.util.Map map)
public static boolean isEmpty(java.lang.Object[] objects)
public static <X,Y> java.util.Map<X,Y> makeCopy(java.util.Map<X,Y> map)
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.