public static final class LRUCache.Builder<K,V>
extends java.lang.Object
ConcurrentLinkedHashMap instances. It
provides a flexible approach for constructing customized instances with
a named parameter syntax. It can be used in the following manner:
ConcurrentMap<Vertex, Set<Edge>> graph = new Builder<Vertex, Set<Edge>>()
.maximumWeightedCapacity(5000)
.weigher(Weighers.<Edge>set())
.build();
| Modifier and Type | Method and Description |
|---|---|
LRUCache<K,V> |
build()
Creates a new
ConcurrentLinkedHashMap instance. |
LRUCache.Builder<K,V> |
concurrencyLevel(int concurrencyLevel)
Specifies the estimated number of concurrently updating threads.
|
LRUCache.Builder<K,V> |
initialCapacity(int initialCapacity)
Specifies the initial capacity of the hash table (default 16).
|
<K1 extends K,V1 extends V> |
listener(EvictionListener<? super K1,? super V1> listener)
Specifies an optional listener that is registered for notification when
an entry is evicted.
|
LRUCache.Builder<K,V> |
maximumSize(long capacity)
Specifies the maximum weighted capacity to coerce the map to and may
exceed it temporarily.
|
static LRUCache.Builder<java.lang.Object,java.lang.Object> |
newBuilder() |
LRUCache.Builder<K,V> |
weigher(EntryWeigher<? super K,? super V> weigher)
Specifies an algorithm to determine how many the units of capacity an
entry consumes.
|
LRUCache.Builder<K,V> |
weigher(Weigher<V> weigher)
Specifies an algorithm to determine how many the units of capacity a
value consumes.
|
public static LRUCache.Builder<java.lang.Object,java.lang.Object> newBuilder()
public LRUCache.Builder<K,V> initialCapacity(int initialCapacity)
initialCapacity - the initial capacity used to size the hash table
to accommodate this many entries.java.lang.IllegalArgumentException - if the initialCapacity is negativepublic LRUCache.Builder<K,V> maximumSize(long capacity)
capacity - the weighted threshold to bound the map byjava.lang.IllegalArgumentException - if the maximumWeightedCapacity is
negativepublic LRUCache.Builder<K,V> concurrencyLevel(int concurrencyLevel)
concurrencyLevel - the estimated number of concurrently updating
threadsjava.lang.IllegalArgumentException - if the concurrencyLevel is less than or
equal to zeropublic <K1 extends K,V1 extends V> LRUCache.Builder<K1,V1> listener(EvictionListener<? super K1,? super V1> listener)
listener - the object to forward evicted entries tojava.lang.NullPointerException - if the listener is nullpublic LRUCache.Builder<K,V> weigher(Weigher<V> weigher)
weigher - the algorithm to determine a value's weightjava.lang.NullPointerException - if the weigher is nullpublic LRUCache.Builder<K,V> weigher(EntryWeigher<? super K,? super V> weigher)
weigher - the algorithm to determine a entry's weightjava.lang.NullPointerException - if the weigher is null