Top Description Fields Constructors Methods
org.hibernate.util

public final Class CollectionHelper

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Collections, .HashMap, .List, .Map, .Set

Various help for handling collections.
Authors
Gavin King, Steve Ebersole

Field Summary

Modifier and TypeField and Description
public static final Collection<E>
public static final List<E>
public static final Map<K, V>
public static final float
public static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> List<T>
arrayList(int anticipatedSize)

public static int

Returns:

The proper size.
determineProperSizing
(Map<K, V>
The original map
original
)

Given a map, determine the proper initial size for a new Map to hold the same number of values.

public static int

Returns:

The proper size.
determineProperSizing
(Set<E>
The original set
original
)

Given a set, determine the proper initial size for a new set to hold the same number of values.

public static int

Returns:

The proper size.
determineProperSizing
(int
The number of elements to be stored.
numberOfElements
)

Determine the proper initial size for a new collection in order for it to hold the given a number of elements.

public static Map<K, V>

Returns:

The sized map.
mapOfSize
(int
The size to make the map.
size
)

Build a properly sized map, especially handling load size and load factor to prevent immediate resizing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_COLLECTIONback to summary
public static final Collection<E> EMPTY_COLLECTION
EMPTY_LISTback to summary
public static final List<E> EMPTY_LIST
EMPTY_MAPback to summary
public static final Map<K, V> EMPTY_MAP
LOAD_FACTORback to summary
public static final float LOAD_FACTOR
MINIMUM_INITIAL_CAPACITYback to summary
public static final int MINIMUM_INITIAL_CAPACITY

Constructor Detail

CollectionHelperback to summary
private CollectionHelper()

Method Detail

arrayListback to summary
public static <T> List<T> arrayList(int anticipatedSize)
determineProperSizingback to summary
public static int determineProperSizing(Map<K, V> 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.

Parameters
original:Map<K, V>

The original map

Returns:int

The proper size.

determineProperSizingback to summary
public static int determineProperSizing(Set<E> 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.

Parameters
original:Set<E>

The original set

Returns:int

The proper size.

determineProperSizingback to summary
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.

Parameters
numberOfElements:int

The number of elements to be stored.

Returns:int

The proper size.

mapOfSizeback to summary
public static 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.

Parameters
size:int

The size to make the map.

Returns:Map<K, V>

The sized map.