Top Description Inners Constructors Methods
org.apache.groovy.util.concurrent.concurrentlinkedhashmap

public final Class Weighers

extends Object
Class Inheritance
Imports
java.io.Serializable, java.util.Collection, .List, .Map, .Set

A common set of Weigher and EntryWeigher implementations.
See Also
http://code.google.com/p/concurrentlinkedhashmap/

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
pack-priv static enum
pack-priv static class
pack-priv static enum
pack-priv static enum
pack-priv static enum
pack-priv static enum
pack-priv static enum
pack-priv static enum

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <K, V> EntryWeigher<K, V>

Returns:

A entry weigher view of the specified weigher.
asEntryWeigher
(final Weigher<? super V>
the weigher to be "wrapped" in a entry weigher.
weigher
)

A entry weigher backed by the specified weigher.

public static Weigher<byte[]>

Returns:

A weigher where each byte takes one unit of capacity.
byteArray
()

A weigher where the value is a byte array and its weight is the number of bytes.

public static <E> Weigher<? super Collection<E>>

Returns:

A weigher where each element takes one unit of capacity.
collection
()

A weigher where the value is a Collection and its weight is the number of elements.

public static <K, V> EntryWeigher<K, V>

Returns:

A weigher where a value takes one unit of capacity.
entrySingleton
()

A weigher where an entry has a weight of 1.

public static <E> Weigher<? super Iterable<E>>

Returns:

A weigher where each element takes one unit of capacity.
iterable
()

A weigher where the value is a Iterable and its weight is the number of elements.

public static <E> Weigher<? super List<E>>

Returns:

A weigher where each element takes one unit of capacity.
list
()

A weigher where the value is a List and its weight is the number of elements.

public static <A, B> Weigher<? super Map<A, B>>

Returns:

A weigher where each entry takes one unit of capacity.
map
()

A weigher where the value is a Map and its weight is the number of entries.

public static <E> Weigher<? super Set<E>>

Returns:

A weigher where each element takes one unit of capacity.
set
()

A weigher where the value is a Set and its weight is the number of elements.

public static <V> Weigher<V>

Returns:

A weigher where a value takes one unit of capacity.
singleton
()

A weigher where a value has a weight of 1.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Weighersback to summary
private Weighers()

Method Detail

asEntryWeigherback to summary
public static <K, V> EntryWeigher<K, V> asEntryWeigher(final Weigher<? super V> weigher)

A entry weigher backed by the specified weigher. The weight of the value determines the weight of the entry.

Parameters
weigher:Weigher<? super V>

the weigher to be "wrapped" in a entry weigher.

Returns:EntryWeigher<K, V>

A entry weigher view of the specified weigher.

byteArrayback to summary
public static Weigher<byte[]> byteArray()

A weigher where the value is a byte array and its weight is the number of bytes. A map bounded with this weigher will evict when the number of bytes exceeds the capacity rather than the number of key-value pairs in the map. This allows for restricting the capacity based on the memory-consumption and is primarily for usage by dedicated caching servers that hold the serialized data.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<byte[]>

A weigher where each byte takes one unit of capacity.

collectionback to summary
public static <E> Weigher<? super Collection<E>> collection()

A weigher where the value is a Collection and its weight is the number of elements. A map bounded with this weigher will evict when the total number of elements exceeds the capacity rather than the number of key-value pairs in the map.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<? super Collection<E>>

A weigher where each element takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
entrySingletonback to summary
public static <K, V> EntryWeigher<K, V> entrySingleton()

A weigher where an entry has a weight of 1. A map bounded with this weigher will evict when the number of key-value pairs exceeds the capacity.

Returns:EntryWeigher<K, V>

A weigher where a value takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
iterableback to summary
public static <E> Weigher<? super Iterable<E>> iterable()

A weigher where the value is a Iterable and its weight is the number of elements. This weigher only should be used when the alternative collection() weigher cannot be, as evaluation takes O(n) time. A map bounded with this weigher will evict when the total number of elements exceeds the capacity rather than the number of key-value pairs in the map.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<? super Iterable<E>>

A weigher where each element takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
listback to summary
public static <E> Weigher<? super List<E>> list()

A weigher where the value is a List and its weight is the number of elements. A map bounded with this weigher will evict when the total number of elements exceeds the capacity rather than the number of key-value pairs in the map.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<? super List<E>>

A weigher where each element takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
mapback to summary
public static <A, B> Weigher<? super Map<A, B>> map()

A weigher where the value is a Map and its weight is the number of entries. A map bounded with this weigher will evict when the total number of entries across all values exceeds the capacity rather than the number of key-value pairs in the map.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<? super Map<A, B>>

A weigher where each entry takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
setback to summary
public static <E> Weigher<? super Set<E>> set()

A weigher where the value is a Set and its weight is the number of elements. A map bounded with this weigher will evict when the total number of elements exceeds the capacity rather than the number of key-value pairs in the map.

A value with a weight of 0 will be rejected by the map. If a value with this weight can occur then the caller should eagerly evaluate the value and treat it as a removal operation. Alternatively, a custom weigher may be specified on the map to assign an empty value a positive weight.

Returns:Weigher<? super Set<E>>

A weigher where each element takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
singletonback to summary
public static <V> Weigher<V> singleton()

A weigher where a value has a weight of 1. A map bounded with this weigher will evict when the number of key-value pairs exceeds the capacity.

Returns:Weigher<V>

A weigher where a value takes one unit of capacity.

Annotations
@SuppressWarnings:cast, unchecked
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.ByteArrayWeigher

extends Enum<Weighers.ByteArrayWeigher>
implements Weigher<byte[]>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.ByteArrayWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.ByteArrayWeigher
public static Weighers.ByteArrayWeigher[]
public int
weightOf(byte[]
the object to weigh
value
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.ByteArrayWeigher INSTANCE

Constructor Detail

ByteArrayWeigherback to summary
private ByteArrayWeigher()

Method Detail

valueOfback to summary
public static Weighers.ByteArrayWeigher valueOf(String name)
valuesback to summary
public static Weighers.ByteArrayWeigher[] values()
weightOfback to summary
public int weightOf(byte[] value)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
value:byte[]

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.CollectionWeigher

extends Enum<Weighers.CollectionWeigher>
implements Weigher<Collection<?>>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.CollectionWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.CollectionWeigher
public static Weighers.CollectionWeigher[]
public int
weightOf(Collection<?>
the object to weigh
values
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.CollectionWeigher INSTANCE

Constructor Detail

CollectionWeigherback to summary
private CollectionWeigher()

Method Detail

valueOfback to summary
public static Weighers.CollectionWeigher valueOf(String name)
valuesback to summary
public static Weighers.CollectionWeigher[] values()
weightOfback to summary
public int weightOf(Collection<?> values)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
values:Collection<?>

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Class Weighers.EntryWeigherView<K, V>

extends Object
implements EntryWeigher<K, V>, Serializable
Class Inheritance
  • java.lang.Object
  • org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weighers.EntryWeigherView
All Implemented Interfaces
java.io.Serializable, org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher

Field Summary

Modifier and TypeField and Description
pack-priv static final long
pack-priv final Weigher<? super V>

Constructor Summary

AccessConstructor and Description
pack-priv
EntryWeigherView(Weigher<? super V> weigher)

Method Summary

Modifier and TypeMethod and Description
public int
weightOf(K
the key to weigh
key
,
V
the value to weigh
value
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Measures an entry's weight to determine how many units of capacity that the key and value consumes.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
pack-priv static final long serialVersionUID
weigherback to summary
pack-priv final Weigher<? super V> weigher

Constructor Detail

EntryWeigherViewback to summary
pack-priv EntryWeigherView(Weigher<? super V> weigher)

Method Detail

weightOfback to summary
public int weightOf(K key, V value)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Measures an entry's weight to determine how many units of capacity that the key and value consumes. An entry must consume a minimum of one unit.

Parameters
key:K

the key to weigh

value:V

the value to weigh

Returns:int

the entry's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.IterableWeigher

extends Enum<Weighers.IterableWeigher>
implements Weigher<Iterable<?>>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.IterableWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.IterableWeigher
public static Weighers.IterableWeigher[]
public int
weightOf(Iterable<?>
the object to weigh
values
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.IterableWeigher INSTANCE

Constructor Detail

IterableWeigherback to summary
private IterableWeigher()

Method Detail

valueOfback to summary
public static Weighers.IterableWeigher valueOf(String name)
valuesback to summary
public static Weighers.IterableWeigher[] values()
weightOfback to summary
public int weightOf(Iterable<?> values)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
values:Iterable<?>

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.ListWeigher

extends Enum<Weighers.ListWeigher>
implements Weigher<List<?>>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.ListWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.ListWeigher
public static Weighers.ListWeigher[]
public int
weightOf(List<?>
the object to weigh
values
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.ListWeigher INSTANCE

Constructor Detail

ListWeigherback to summary
private ListWeigher()

Method Detail

valueOfback to summary
public static Weighers.ListWeigher valueOf(String name)
valuesback to summary
public static Weighers.ListWeigher[] values()
weightOfback to summary
public int weightOf(List<?> values)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
values:List<?>

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.MapWeigher

extends Enum<Weighers.MapWeigher>
implements Weigher<Map<?, ?>>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.MapWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.MapWeigher
public static Weighers.MapWeigher[]
public int
weightOf(Map<?, ?>
the object to weigh
values
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.MapWeigher INSTANCE

Constructor Detail

MapWeigherback to summary
private MapWeigher()

Method Detail

valueOfback to summary
public static Weighers.MapWeigher valueOf(String name)
valuesback to summary
public static Weighers.MapWeigher[] values()
weightOfback to summary
public int weightOf(Map<?, ?> values)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
values:Map<?, ?>

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.SetWeigher

extends Enum<Weighers.SetWeigher>
implements Weigher<Set<?>>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.SetWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.SetWeigher
public static Weighers.SetWeigher[]
public int
weightOf(Set<?>
the object to weigh
values
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.SetWeigher INSTANCE

Constructor Detail

SetWeigherback to summary
private SetWeigher()

Method Detail

valueOfback to summary
public static Weighers.SetWeigher valueOf(String name)
valuesback to summary
public static Weighers.SetWeigher[] values()
weightOfback to summary
public int weightOf(Set<?> values)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
values:Set<?>

the object to weigh

Returns:int

the object's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.SingletonEntryWeigher

extends Enum<Weighers.SingletonEntryWeigher>
implements EntryWeigher<Object, Object>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.SingletonEntryWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.SingletonEntryWeigher
public static Weighers.SingletonEntryWeigher[]
public int
weightOf(Object
the key to weigh
key
,
Object
the value to weigh
value
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Measures an entry's weight to determine how many units of capacity that the key and value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.SingletonEntryWeigher INSTANCE

Constructor Detail

SingletonEntryWeigherback to summary
private SingletonEntryWeigher()

Method Detail

valueOfback to summary
public static Weighers.SingletonEntryWeigher valueOf(String name)
valuesback to summary
public static Weighers.SingletonEntryWeigher[] values()
weightOfback to summary
public int weightOf(Object key, Object value)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.EntryWeigher.weightOf.

Measures an entry's weight to determine how many units of capacity that the key and value consumes. An entry must consume a minimum of one unit.

Parameters
key:Object

the key to weigh

value:Object

the value to weigh

Returns:int

the entry's weight

Annotations
@Override
org.apache.groovy.util.concurrent.concurrentlinkedhashmap back to summary

pack-priv final Enum Weighers.SingletonWeigher

extends Enum<Weighers.SingletonWeigher>
implements Weigher<Object>
Class Inheritance
All Implemented Interfaces
org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher

Field Summary

Modifier and TypeField and Description
public static final Weighers.SingletonWeigher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Weighers.SingletonWeigher
public static Weighers.SingletonWeigher[]
public int
weightOf(Object
the object to weigh
value
)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes.
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Weighers.SingletonWeigher INSTANCE

Constructor Detail

SingletonWeigherback to summary
private SingletonWeigher()

Method Detail

valueOfback to summary
public static Weighers.SingletonWeigher valueOf(String name)
valuesback to summary
public static Weighers.SingletonWeigher[] values()
weightOfback to summary
public int weightOf(Object value)

Implements org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Doc from org.apache.groovy.util.concurrent.concurrentlinkedhashmap.Weigher.weightOf.

Measures an object's weight to determine how many units of capacity that the value consumes. A value must consume a minimum of one unit.

Parameters
value:Object

the object to weigh

Returns:int

the object's weight

Annotations
@Override