public class Hash2<K,V> extends Object
OptimisticLock
Constructor and Description |
---|
Hash2() |
Modifier and Type | Method and Description |
---|---|
long |
calcEntryCount()
Count the entries in the hash table, by scanning through the hash table.
|
void |
calcHashCollisionInfo(CollisionInfo inf) |
void |
checkExpand(int _hash)
Checks whether expansion is needed and expand when
insertWithinLock(Entry, int) is used. |
void |
clearWhenLocked() |
void |
close()
Close the cache by discarding the entry table.
|
int |
getClearOrCloseCount() |
Entry<K,V>[] |
getEntries()
Entry table for used by the iterator.
|
OptimisticLock |
getSegmentLock(int _hash) |
long |
getSize() |
Entry<K,V> |
insertWithinLock(Entry<K,V> e,
int _hash)
Insert an entry.
|
boolean |
isClosed() |
Entry<K,V> |
lookup(K key,
int _hash)
Lookup the entry in the hash table and return it.
|
boolean |
remove(Entry<K,V> e)
Remove existing entry from the hash.
|
boolean |
removeWithinLock(Entry<K,V> e,
int _hash) |
<T> T |
runTotalLocked(Job<T> j)
Lock all segments and run the job.
|
public Entry<K,V> lookup(K key, int _hash)
public Entry<K,V> insertWithinLock(Entry<K,V> e, int _hash)
public void checkExpand(int _hash)
insertWithinLock(Entry, int)
is used.
No lock may be hold when calling this method, since the table must be locked completely using
the proper lock order.
Need for expansion is only checked by comparing whether the associated segment is full. Should be called after insert after giving up the lock.
public OptimisticLock getSegmentLock(int _hash)
public boolean remove(Entry<K,V> e)
public long getSize()
public <T> T runTotalLocked(Job<T> j)
public void clearWhenLocked()
public int getClearOrCloseCount()
public void close()
Closing will be visible to other threads, because of the guarantees of the locking. Using the entry table for closing has the advantage that the close check collapses with the implicit null check and has no additional overhead.
public void calcHashCollisionInfo(CollisionInfo inf)
public long calcEntryCount()
public boolean isClosed()
cache2k API documentation. Copyright © 2000–2018 headissue GmbH, Munich.