public final class ConcurrentARC<K,V> extends java.util.AbstractMap<K,V> implements java.util.Map<K,V>, java.lang.Iterable<java.util.Map.Entry<K,V>>, ARC<K,V>
Modifier and Type | Field and Description |
---|---|
private ARC<K,V>[] |
arc |
private int |
mask |
Constructor and Description |
---|
ConcurrentARC(int cacheSize,
int partitions)
create a concurrent ARC based on a HashARC.
|
ConcurrentARC(int cacheSize,
int partitions,
java.util.Comparator<? super K> comparator)
create a concurrent ARC based on a ComparableARC
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
clear the cache
|
boolean |
containsKey(java.lang.Object s)
check if the map contains the key
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Return a Set view of the mappings contained in this map.
|
V |
get(java.lang.Object s)
get a value from the cache.
|
java.util.Collection<K> |
getKeys(V value)
check if the map contains the value
|
private int |
getPartition(java.lang.Object x)
return in which partition the Object belongs
This function uses the objects hashCode() function
except for byte[] keys
|
int |
hashCode()
a hash code for this ARC
|
void |
insert(K s,
V v)
put a value to the cache.
|
void |
insertIfAbsent(K s,
V v)
put a value to the cache if there was not an entry before
do not return a previous content value
|
java.util.Iterator<java.util.Map.Entry<K,V>> |
iterator()
iterator implements the Iterable interface
|
static void |
main(java.lang.String[] args) |
V |
put(K s,
V v)
put a value to the cache.
|
V |
putIfAbsent(K s,
V v)
put a value to the cache if there was not an entry before
return a previous content value
|
V |
remove(java.lang.Object s)
remove an entry from the cache
|
int |
size()
get the size of the ARC.
|
clone, containsValue, equals, isEmpty, keySet, putAll, toString, values
public ConcurrentARC(int cacheSize, int partitions)
cacheSize
- the number of maximum entriespartitions
- the number of partitionspublic ConcurrentARC(int cacheSize, int partitions, java.util.Comparator<? super K> comparator)
cacheSize
- the number of maximum entriespartitions
- the number of partitionscomparator
- a comparator for the key object which may be of type byte[]public void insertIfAbsent(K s, V v)
insertIfAbsent
in interface ARC<K,V>
s
- v
- public V putIfAbsent(K s, V v)
putIfAbsent
in interface ARC<K,V>
s
- v
- public final V get(java.lang.Object s)
public final boolean containsKey(java.lang.Object s)
public final V remove(java.lang.Object s)
public final void clear()
public final int size()
public java.util.Iterator<java.util.Map.Entry<K,V>> iterator()
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
public int hashCode()
private int getPartition(java.lang.Object x)
public static void main(java.lang.String[] args)