All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.unterrainer.commons.jreutils.collections.SizeLimitedHashMap Maven / Gradle / Ivy

There is a newer version: 0.3.15
Show newest version
package info.unterrainer.commons.jreutils.collections;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * A size-limited hash-map.
 */
public class SizeLimitedHashMap extends LinkedHashMap {
	private static final long serialVersionUID = 6994714918898609875L;

	private final int maxSize;

	public SizeLimitedHashMap(final int maxSize) {
		this.maxSize = maxSize;
	}

	@Override
	protected boolean removeEldestEntry(final Map.Entry eldest) {
		return size() > maxSize;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy