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

org.stone.tools.LruCache Maven / Gradle / Ivy

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright(C) Chris2018998,All rights reserved.
 *
 * Project owner contact:[email protected].
 *
 * Project Licensed under Apache License v2.0.
 */
package org.stone.tools;

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

/**
 * Lru Cache
 *
 * @author Chris Liao
 * @version 1.0
 */
public class LruCache extends LinkedHashMap {
    private final int maxSize;

    public LruCache(int maxSize) {
        super(maxSize, 0.75F, true);
        this.maxSize = maxSize;
    }

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy