com.ibm.wala.util.collections.HashMapFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.ibm.wala.util Show documentation
Show all versions of com.ibm.wala.util Show documentation
T. J. Watson Libraries for Analysis
The newest version!
/*
* Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*/
package com.ibm.wala.util.collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* A debugging aid. When HashSetFactory.DEBUG is set, this class creates ParanoidHashMaps.
* Otherwise, it returns {@link LinkedHashMap}
*/
public class HashMapFactory {
/**
* @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
*/
public static HashMap make(int size) {
if (HashSetFactory.DEBUG) {
return new ParanoidHashMap<>(size);
} else {
return new LinkedHashMap<>(size);
}
}
/**
* @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
*/
public static HashMap make() {
if (HashSetFactory.DEBUG) {
return new ParanoidHashMap<>();
} else {
return new LinkedHashMap<>();
}
}
/**
* @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
*/
public static HashMap make(Map t) {
if (t == null) {
throw new IllegalArgumentException("null t");
}
if (HashSetFactory.DEBUG) {
return new ParanoidHashMap<>(t);
} else {
return new LinkedHashMap<>(t);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy