public class

CacheMap

extends HashMap<K, V>
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ com.pnfsoftware.jeb.util.collect.CacheMap<K, V>

Class Overview

A simple cache map. The use of putAll(Map) is forbidden; only put(Object, Object) and get(Object) operations are permitted.

Summary

Public Constructors
CacheMap(int maxSize, int evictSize)
Construct a cache map.
CacheMap(int maxSize)
Construct a cache map with an eviction size of 1.
Public Methods
V get(Object key)
V put(K key, V val)
void putAll(Map<? extends K, ? extends V> map)
[Expand]
Inherited Methods
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface java.util.Map

Public Constructors

public CacheMap (int maxSize, int evictSize)

Construct a cache map. Whenever an element is added and the map exceeds the maximum size, it will be partially cleaned up by evicting the last accessed objects.

Parameters
maxSize maximum size of the cache map
evictSize number of objects evicted during a partial cache cleanup

public CacheMap (int maxSize)

Construct a cache map with an eviction size of 1.

Parameters
maxSize maximum size of the map

Public Methods

public V get (Object key)

public V put (K key, V val)

public void putAll (Map<? extends K, ? extends V> map)