public class DefaultAttributeMap extends java.lang.Object implements AttributeMap
AttributeMap implementation which use simple synchronization per bucket to keep the memory overhead
as low as possible.| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultAttributeMap.DefaultAttribute<T> |
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicReferenceArray<DefaultAttributeMap.DefaultAttribute<?>> |
attributes |
private static int |
BUCKET_SIZE |
private static int |
MASK |
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DefaultAttributeMap,java.util.concurrent.atomic.AtomicReferenceArray> |
updater |
| Constructor and Description |
|---|
DefaultAttributeMap() |
| Modifier and Type | Method and Description |
|---|---|
<T> Attribute<T> |
attr(AttributeKey<T> key)
Get the
Attribute for the given AttributeKey. |
<T> boolean |
hasAttr(AttributeKey<T> key)
Returns true if and only if the given
Attribute exists in this AttributeMap. |
private static int |
index(AttributeKey<?> key) |
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DefaultAttributeMap,java.util.concurrent.atomic.AtomicReferenceArray> updater
private static final int BUCKET_SIZE
private static final int MASK
private volatile java.util.concurrent.atomic.AtomicReferenceArray<DefaultAttributeMap.DefaultAttribute<?>> attributes
public <T> Attribute<T> attr(AttributeKey<T> key)
AttributeMapAttribute for the given AttributeKey. This method will never return null, but may return
an Attribute which does not have a value set yet.attr in interface AttributeMappublic <T> boolean hasAttr(AttributeKey<T> key)
AttributeMapAttribute exists in this AttributeMap.hasAttr in interface AttributeMapprivate static int index(AttributeKey<?> key)