Package org.apache.myfaces.util.lang
Class HashMapUtils
- java.lang.Object
-
- org.apache.myfaces.util.lang.HashMapUtils
-
public class HashMapUtils extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HashMapUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
calcCapacity(int size)
Calculates initial capacity needed to holdsize
elements in a HashMap or Hashtable without forcing an expensive increase in internal capacity.static String
mapToString(Map map)
spit out each name/value pairstatic HashMap
merge(Map map1, Map map2)
Creates a newHashMap
that has all of the elements ofmap1
andmap2
(on key collision, the latter override the former).
-
-
-
Method Detail
-
calcCapacity
public static final int calcCapacity(int size)
Calculates initial capacity needed to holdsize
elements in a HashMap or Hashtable without forcing an expensive increase in internal capacity. Capacity is based on the default load factor of .75.Usage:
Map map = new HashMap(HashMapUtils.calcCapacity(10));
- Parameters:
size
- the number of items that will be put into a HashMap- Returns:
- initial capacity needed
-
merge
public static HashMap merge(Map map1, Map map2)
Creates a newHashMap
that has all of the elements ofmap1
andmap2
(on key collision, the latter override the former).- Parameters:
map1
- the fist hashmap to mergemap2
- the second hashmap to merge- Returns:
- new hashmap
-
-