K
- キー型 V
- 値の型 public class ConcurrentReferenceHashMap<K,V> extends AbstractMapSE<K,V> implements ConcurrentMapSE<K,V>
soft
または keys
と values
の両方に弱い参照を使用する ConcurrentHashMap
SE。 このクラスは、同時にアクセスしたときにパフォーマンスを向上させるために、Collections.synchronizedMap(new WeakHashMap<K, Reference<V>>())
の代替として使用できます。この実装は、null
値と null
キーがサポートされていることを除いて、ConcurrentHashMap
SE と同じ設計上の制約に従います。
注意 : 参照の使用は、マップに配置されたアイテムが後で利用可能になるという保証がないことを意味します。ガベージコレクターはいつでも参照を破棄する可能性があるため、不明なスレッドが静かにエントリを削除しているように見えることがあります。
明示的に指定されていない場合、この実装はソフトエントリ参照SEを使用します。
修飾子と型 | クラスと説明 |
---|---|
protected static class | ConcurrentReferenceHashMap.Entry<K, V> 単一のマップエントリ。 |
protected static interface | ConcurrentReferenceHashMap.Reference<K, V> マップに含まれる ConcurrentReferenceHashMap.Entry への参照。 |
protected class | ConcurrentReferenceHashMap.ReferenceManager References を管理するために使用される戦略クラス。 |
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, keySetSE, putAllSE, toStringSE, valuesSE
finalizeSE, getClassSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
computeSE, computeIfAbsentSE, computeIfPresentSE, forEachSE, mergeSE, replaceAllSE
containsValueSE, equalsSE, hashCodeSE, keySetSE, putAllSE, valuesSE
public 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)
ConcurrentHashMap
SE と同じ Wang/Jenkins アルゴリズムを使用します。サブクラスは、代替ハッシュを提供するためにオーバーライドできます。o
- ハッシュするオブジェクト (null の可能性があります)@Nullable public V getOrDefault(@Nullable ObjectSE key, @Nullable V defaultValue)
ConcurrentMapSE<K, V>
の getOrDefaultSE
MapSE<K, V>
の getOrDefaultSE
public boolean containsKey(@Nullable 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(@Nullable K key, @Nullable V value)
ConcurrentMapSE<K, V>
の putIfAbsentSE
MapSE<K, V>
の putIfAbsentSE
public void clear()
public void purgeUnreferencedEntries()
public boolean isEmpty()
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
を使用して値を取得する)