/** * Create a hash map from another associative container. (constructor shortcut) Default load factor is used. */ public static <KType, VType> ObjectObjectHashMap<KType, VType> from( final ObjectObjectAssociativeContainer<KType, VType> container) { return new ObjectObjectHashMap<KType, VType>(container); }
/** * Create a new hash map with initial capacity and load factor control. * (constructor shortcut). */ public static <KType, VType> ObjectObjectHashMap<KType, VType> newInstance(final int initialCapacity, final double loadFactor) { return new ObjectObjectHashMap<KType, VType>(initialCapacity, loadFactor); }
/** * Create a new hash map without providing the full generic signature * (constructor shortcut). */ public static <KType, VType> ObjectObjectHashMap<KType, VType> newInstance() { return new ObjectObjectHashMap<KType, VType>(); }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. Default load factor is used. */ public static <KType, VType> ObjectObjectHashMap<KType, VType> from(final KType[] keys, final VType[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } final ObjectObjectHashMap<KType, VType> map = new ObjectObjectHashMap<KType, VType>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * {@inheritDoc} */ @Override public ObjectObjectHashMap<KType, VType> clone() { //clone to size() to prevent some cases of exponential sizes, final ObjectObjectHashMap<KType, VType> cloned = new ObjectObjectHashMap<KType, VType>(this.size(), this.loadFactor); //We must NOT clone because of independent perturbations seeds cloned.putAll(this); return cloned; }