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

io.polaris.core.map.LimitedLinkedHashMap Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.polaris.core.map;

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

/**
 * @author Qt
 * @since 1.8
 */
public class LimitedLinkedHashMap extends LinkedHashMap {

	private int maxCapacity = 0;

	public LimitedLinkedHashMap(int maxCapacity) {
		this.maxCapacity = maxCapacity;
	}

	public LimitedLinkedHashMap(int maxCapacity, boolean accessOrder) {
		super(16, .75f, accessOrder);
		this.maxCapacity = maxCapacity;
	}

	public LimitedLinkedHashMap(int maxCapacity, boolean accessOrder, int initialCapacity, float loadFactor) {
		super(initialCapacity, loadFactor, accessOrder);
		this.maxCapacity = maxCapacity;
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy