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

org.checkerframework.javacutil.CollectionUtils Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java's type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.43.0
Show newest version
package org.checkerframework.javacutil;

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

/** Utility methods related to Java Collections. */
public class CollectionUtils {

  /**
   * Creates a LRU cache.
   *
   * @param size size of the cache
   * @return a new cache with the provided size
   */
  public static  Map createLRUCache(final int size) {
    return new LinkedHashMap(size, .75F, true) {

      private static final long serialVersionUID = 5261489276168775084L;

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy