类 CollectionHelper
- java.lang.Object
-
- org.hibernate.internal.util.collections.CollectionHelper
-
public final class CollectionHelper extends Object
Various help for handling collections.- 作者:
- Gavin King, Steve Ebersole
-
-
字段概要
字段 修饰符和类型 字段 说明 static CollectionEMPTY_COLLECTION已过时。useCollections.EMPTY_LISTorCollections.emptyList()insteadstatic ListEMPTY_LIST已过时。useCollections.EMPTY_LISTorCollections.emptyList()insteadstatic MapEMPTY_MAP已过时。useCollections.EMPTY_MAPorCollections.emptyMap()insteadstatic floatLOAD_FACTORstatic intMINIMUM_INITIAL_CAPACITY
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> ArrayList<T>arrayList(int anticipatedSize)static <K,V>
ConcurrentHashMap<K,V>concurrentMap(int expectedNumberOfElements)Create a properly sizedConcurrentHashMapbased on the given expected number of elements.static <K,V>
ConcurrentHashMap<K,V>concurrentMap(int expectedNumberOfElements, float loadFactor)Create a properly sizedConcurrentHashMapbased on the given expected number of elements and an explicit load factorstatic intdetermineProperSizing(int numberOfElements)Determine the proper initial size for a new collection in order for it to hold the given a number of elements.static intdetermineProperSizing(Map original)Given a map, determine the proper initial size for a new Map to hold the same number of values.static intdetermineProperSizing(Set original)Given a set, determine the proper initial size for a new set to hold the same number of values.static booleanisEmpty(Object[] objects)static booleanisEmpty(Collection collection)static booleanisEmpty(Map map)static booleanisNotEmpty(Collection collection)static booleanisNotEmpty(Map map)static <K,V>
HashMap<K,V>makeCopy(Map<K,V> original, Function<K,K> keyTransformer, Function<V,V> valueTransformer)static <X,Y>
Map<X,Y>makeCopy(Map<X,Y> map)static <T> Set<T>makeCopy(Set<T> source)static <K,V,E>
Map<K,V>makeMap(Collection<E> collection, Function<E,K> keyProducer, Function<E,V> valueProducer)static <K,V>
Map<K,V>makeMap(Collection<V> collection, Function<V,K> keyProducer)static <K,V>
Map<K,V>mapOfSize(int size)Build a properly sized map, especially handling load size and load factor to prevent immediate resizing.
-
-
-
字段详细资料
-
MINIMUM_INITIAL_CAPACITY
public static final int MINIMUM_INITIAL_CAPACITY
- 另请参阅:
- 常量字段值
-
LOAD_FACTOR
public static final float LOAD_FACTOR
- 另请参阅:
- 常量字段值
-
EMPTY_LIST
@Deprecated public static final List EMPTY_LIST
已过时。useCollections.EMPTY_LISTorCollections.emptyList()instead
-
EMPTY_COLLECTION
@Deprecated public static final Collection EMPTY_COLLECTION
已过时。useCollections.EMPTY_LISTorCollections.emptyList()instead
-
EMPTY_MAP
@Deprecated public static final Map EMPTY_MAP
已过时。useCollections.EMPTY_MAPorCollections.emptyMap()instead
-
-
方法详细资料
-
mapOfSize
public static <K,V> Map<K,V> mapOfSize(int size)
Build a properly sized map, especially handling load size and load factor to prevent immediate resizing. Especially helpful for copy map contents.- 参数:
size- The size to make the map.- 返回:
- The sized map.
-
determineProperSizing
public static int determineProperSizing(Map original)
Given a map, determine the proper initial size for a new Map to hold the same number of values. Specifically we want to account for load size and load factor to prevent immediate resizing.- 参数:
original- The original map- 返回:
- The proper size.
-
makeCopy
public static <K,V> HashMap<K,V> makeCopy(Map<K,V> original, Function<K,K> keyTransformer, Function<V,V> valueTransformer)
-
makeMap
public static <K,V> Map<K,V> makeMap(Collection<V> collection, Function<V,K> keyProducer)
-
makeMap
public static <K,V,E> Map<K,V> makeMap(Collection<E> collection, Function<E,K> keyProducer, Function<E,V> valueProducer)
-
determineProperSizing
public static int determineProperSizing(Set original)
Given a set, determine the proper initial size for a new set to hold the same number of values. Specifically we want to account for load size and load factor to prevent immediate resizing.- 参数:
original- The original set- 返回:
- The proper size.
-
determineProperSizing
public 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. Specifically we want to account for load size and load factor to prevent immediate resizing.- 参数:
numberOfElements- The number of elements to be stored.- 返回:
- The proper size.
-
concurrentMap
public static <K,V> ConcurrentHashMap<K,V> concurrentMap(int expectedNumberOfElements)
Create a properly sizedConcurrentHashMapbased on the given expected number of elements.- 类型参数:
K- The map key typeV- The map value type- 参数:
expectedNumberOfElements- The expected number of elements for the created map- 返回:
- The created map.
-
concurrentMap
public static <K,V> ConcurrentHashMap<K,V> concurrentMap(int expectedNumberOfElements, float loadFactor)
Create a properly sizedConcurrentHashMapbased on the given expected number of elements and an explicit load factor- 类型参数:
K- The map key typeV- The map value type- 参数:
expectedNumberOfElements- The expected number of elements for the created maploadFactor- The collection load factor- 返回:
- The created map.
-
arrayList
public static <T> ArrayList<T> arrayList(int anticipatedSize)
-
isEmpty
public static boolean isEmpty(Collection collection)
-
isEmpty
public static boolean isEmpty(Map map)
-
isNotEmpty
public static boolean isNotEmpty(Collection collection)
-
isNotEmpty
public static boolean isNotEmpty(Map map)
-
isEmpty
public static boolean isEmpty(Object[] objects)
-
-