Module openj9.dtfj

Class IntegerLruCache

All Implemented Interfaces:
Serializable

public final class IntegerLruCache extends AbstractLruCache
This class provides an LRU (Least Recently Used) cache which maps integer keys to int values. See the description in the superclass AbstractLruCache for more details. Like its sibling IntegerMap it is low footprint. Note that the value -1 is not allowed (see discussion in IntegerMap).
See Also:
  • Constructor Details

    • IntegerLruCache

      public IntegerLruCache(int maxSize)
      Create a new IntegerLruCache.
      Parameters:
      maxSize - the maximum size the cache can grow to
  • Method Details

    • get

      public int get(long key)
      Returns the value mapped by the given key. Also promotes this key to the most recently used.
      Returns:
      the value or -1 if it cannot be found
    • put

      public void put(long key, int value)
      Add the key/value pair to the map. The value must not be -1.
    • main

      public static void main(String[] args)
      Run some basic tests on this class.