K - キー型 V - 値の型 public class ConcurrentReferenceHashMap<K,V> extends AbstractMapSE<K,V> implements ConcurrentMapSE<K,V>
soft または keys と values の両方に弱い参照を使用する ConcurrentHashMapSE。 このクラスは、同時にアクセスしたときにパフォーマンスを向上させるために、Collections.synchronizedMap(new WeakHashMap<K, Reference<V>>()) の代替として使用できます。この実装は、null 値と null キーがサポートされていることを除いて、ConcurrentHashMapSE と同じ設計上の制約に従います。
注意 : 参照の使用は、マップに配置されたアイテムが後で利用可能になるという保証がないことを意味します。ガベージコレクターはいつでも参照を破棄する可能性があるため、不明なスレッドが静かにエントリを削除しているように見えることがあります。
明示的に指定されていない場合、この実装はソフトエントリ参照SEを使用します。
| 修飾子と型 | クラスと説明 |
|---|---|
protected static class | ConcurrentReferenceHashMap.Entry<K, V> 単一のマップエントリ。 |
protected static interface | ConcurrentReferenceHashMap.Reference<K, V> マップに含まれる ConcurrentReferenceHashMap.Entry への参照。 |
protected class | ConcurrentReferenceHashMap.ReferenceManagerConcurrentReferenceHashMap.Reference の管理に使用される戦略クラス。 |
static class | ConcurrentReferenceHashMap.ReferenceType このマップでサポートされるさまざまな参照型。 |
protected static class | ConcurrentReferenceHashMap.Restructure 実行できる再構築の種類。 |
protected class | ConcurrentReferenceHashMap.Segment 同時パフォーマンスを向上させるためにマップを分割するために使用される単一のセグメント。 |
AbstractMap.SimpleEntrySE<KSE, VSE>, AbstractMap.SimpleImmutableEntrySE<KSE, VSE>| コンストラクターと説明 |
|---|
ConcurrentReferenceHashMap() 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity, float loadFactor) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, ConcurrentReferenceHashMap.ReferenceType referenceType) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
ConcurrentReferenceHashMap(int initialCapacity, int concurrencyLevel) 新しい ConcurrentReferenceHashMap インスタンスを作成します。 |
cloneSE, containsValueSE, equalsSE, hashCodeSE, isEmptySE, keySetSE, putAllSE, toStringSE, valuesSEfinalizeSE, getClassSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEcomputeSE, computeIfAbsentSE, computeIfPresentSE, forEachSE, getOrDefaultSE, mergeSE, replaceAllSEcontainsValueSE, equalsSE, hashCodeSE, isEmptySE, keySetSE, putAllSE, valuesSEpublic ConcurrentReferenceHashMap()
ConcurrentReferenceHashMap インスタンスを作成します。public ConcurrentReferenceHashMap(int initialCapacity)
ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 public ConcurrentReferenceHashMap(int initialCapacity,
float loadFactor)ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 loadFactor - 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます public ConcurrentReferenceHashMap(int initialCapacity,
int concurrencyLevel)ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 concurrencyLevel - 同時にマップに書き込むスレッドの予想数 public ConcurrentReferenceHashMap(int initialCapacity,
ConcurrentReferenceHashMap.ReferenceType referenceType)ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 referenceType - エントリに使用される参照型 (柔らかいか弱い)public ConcurrentReferenceHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 loadFactor - 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます。concurrencyLevel - 同時にマップに書き込むスレッドの予想数 public ConcurrentReferenceHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel,
ConcurrentReferenceHashMap.ReferenceType referenceType)ConcurrentReferenceHashMap インスタンスを作成します。initialCapacity - マップの初期容量 loadFactor - 負荷率。テーブルごとの平均参照数がこの値を超えると、サイズ変更が試行されます。concurrencyLevel - 同時にマップに書き込むスレッドの予想数 referenceType - エントリに使用される参照型 (柔らかいか弱い)protected final float getLoadFactor()
protected final int getSegmentsSize()
protected final ConcurrentReferenceHashMap.Segment getSegment(int index)
protected ConcurrentReferenceHashMap.ReferenceManager createReferenceManager()
ConcurrentReferenceHashMap.ReferenceManager を返すファクトリメソッド。このメソッドは、各 ConcurrentReferenceHashMap.Segment に対して 1 回呼び出されます。protected int getHash(@Nullable ObjectSE o)
ConcurrentHashMapSE と同じ Wang/Jenkins アルゴリズムを使用します。サブクラスは、代替ハッシュを提供するためにオーバーライドできます。o - ハッシュするオブジェクト (null の可能性があります)public boolean containsKey(ObjectSE key)
MapSE<K, V> の containsKeySE AbstractMapSE<K, V> の containsKeySE @Nullable protected final ConcurrentReferenceHashMap.Reference<K,V> getReference(@Nullable ObjectSE key, ConcurrentReferenceHashMap.Restructure restructure)
key の ConcurrentReferenceHashMap.Reference を ConcurrentReferenceHashMap.Entry に返します。見つからない場合は null を返します。key - キー (null にすることができます)restructure - この呼び出し中に許可される再構築の型 null @Nullable public V putIfAbsent(K key, V value)
ConcurrentMapSE<K, V> の putIfAbsentSE MapSE<K, V> の putIfAbsentSE public void clear()
public void purgeUnreferencedEntries()
public SetSE<Map.EntrySE<K,V>> entrySet()
MapSE<K, V> の entrySetSE AbstractMapSE<K, V> の entrySetSE protected static int calculateShift(int minimumValue,
int maximumValue)minimumValue - 最小値 maximumValue - 最大値 1 << shift を使用して値を取得する)