Build 1.0_r1(from source)

java.util.concurrent
Class ConcurrentHashMap.Segment<K,V>

java.lang.Object
  extended by java.util.concurrent.locks.ReentrantLock
      extended by java.util.concurrent.ConcurrentHashMap.Segment<K,V>
All Implemented Interfaces:
Serializable, Lock
Enclosing class:
ConcurrentHashMap<K,V>

static final class ConcurrentHashMap.Segment<K,V>
extends ReentrantLock
implements Serializable

Segments are specialized versions of hash tables. This subclasses from ReentrantLock opportunistically, just to simplify some locking and avoid separate construction.


Field Summary
(package private)  int count
          The number of elements in this segment's region.
(package private)  float loadFactor
          The load factor for the hash table.
(package private)  int modCount
          Number of updates; used for checking lack of modifications in bulk-read methods.
(package private)  ConcurrentHashMap.HashEntry[] table
          The per-segment table
(package private)  int threshold
          The table is rehashed when its size exceeds this threshold.
 
Constructor Summary
ConcurrentHashMap.Segment(int initialCapacity, float lf)
           
 
Method Summary
(package private)  void clear()
           
(package private)  boolean containsKey(Object key, int hash)
           
(package private)  boolean containsValue(Object value)
           
(package private)  V get(Object key, int hash)
           
(package private)  V put(K key, int hash, V value, boolean onlyIfAbsent)
           
(package private)  ConcurrentHashMap.HashEntry[] rehash(ConcurrentHashMap.HashEntry[] oldTable)
           
(package private)  V remove(Object key, int hash, Object value)
          Remove; match on key only if value null, else match both.
(package private)  V replace(K key, int hash, V newValue)
           
(package private)  boolean replace(K key, int hash, V oldValue, V newValue)
           
(package private)  void setTable(ConcurrentHashMap.HashEntry[] newTable)
          Set table to new HashEntry array.
 
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

count

transient volatile int count
The number of elements in this segment's region.


modCount

transient int modCount
Number of updates; used for checking lack of modifications in bulk-read methods.


threshold

transient int threshold
The table is rehashed when its size exceeds this threshold. (The value of this field is always (int)(capacity * loadFactor).)


table

transient ConcurrentHashMap.HashEntry[] table
The per-segment table


loadFactor

final float loadFactor
The load factor for the hash table. Even though this value is same for all segments, it is replicated to avoid needing links to outer object.

Constructor Detail

ConcurrentHashMap.Segment

ConcurrentHashMap.Segment(int initialCapacity,
                          float lf)
Method Detail

setTable

void setTable(ConcurrentHashMap.HashEntry[] newTable)
Set table to new HashEntry array. Call only while holding lock or in constructor.


get

V get(Object key,
      int hash)

containsKey

boolean containsKey(Object key,
                    int hash)

containsValue

boolean containsValue(Object value)

replace

boolean replace(K key,
                int hash,
                V oldValue,
                V newValue)

replace

V replace(K key,
          int hash,
          V newValue)

put

V put(K key,
      int hash,
      V value,
      boolean onlyIfAbsent)

rehash

ConcurrentHashMap.HashEntry[] rehash(ConcurrentHashMap.HashEntry[] oldTable)

remove

V remove(Object key,
         int hash,
         Object value)
Remove; match on key only if value null, else match both.


clear

void clear()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature