public class LeaseTimeMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<K,V> |
map
The map.
|
protected ILeaseTimeSet<K> |
times
Lease time map with keys.
|
protected boolean |
touchonread
Flag if touch on read.
|
protected boolean |
touchonwrite
Flag if touch on read.
|
Constructor and Description |
---|
LeaseTimeMap(long leasetime)
Create a new lease time map.
|
LeaseTimeMap(long leasetime,
ICommand<Tuple2<java.util.Map.Entry<K,V>,java.lang.Long>> removecmd,
boolean touchonread,
boolean touchonwrite,
boolean passive)
Create a new lease time map.
|
LeaseTimeMap(long leasetime,
ICommand<Tuple2<java.util.Map.Entry<K,V>,java.lang.Long>> removecmd,
boolean touchonread,
boolean touchonwrite,
boolean passive,
IDelayRunner timer,
boolean sync)
Create a new lease time map.
|
Modifier and Type | Method and Description |
---|---|
void |
checkStale()
Check for stale entries and remove them.
|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(java.lang.Object key)
Returns
|
boolean |
containsValue(java.lang.Object value)
Returns
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map.
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this map for equality.
|
V |
get(java.lang.Object key)
Returns the collection to which this map maps the specified key.
|
int |
hashCode()
Returns the hash code value for this map.
|
boolean |
isEmpty()
Returns
|
java.util.Set<K> |
keySet()
Returns a set view of the keys contained in this map.
|
static void |
main(java.lang.String[] args)
Main for testing.
|
V |
put(K key,
V value)
Associates the specified value with the specified key in this map
(optional operation).
|
V |
put(K key,
V value,
long leasetime) |
void |
putAll(java.util.Map<? extends K,? extends V> t)
Copies all of the mappings from the specified map to this map
(optional operation).
|
void |
putAll(java.util.Map<? extends K,? extends V> t,
long leasetime) |
V |
remove(java.lang.Object key)
Removes the mapping for this key from this map if it is present.
|
int |
size()
Returns the number of elements added to this map.
|
java.lang.String |
toString()
Create a string representation of this map.
|
void |
touch(K key)
Update the timestamp of e.
|
java.util.Collection<V> |
values()
Unsupported Operation.
|
protected ILeaseTimeSet<K> times
protected boolean touchonread
protected boolean touchonwrite
public LeaseTimeMap(long leasetime)
public LeaseTimeMap(long leasetime, ICommand<Tuple2<java.util.Map.Entry<K,V>,java.lang.Long>> removecmd, boolean touchonread, boolean touchonwrite, boolean passive)
public LeaseTimeMap(long leasetime, ICommand<Tuple2<java.util.Map.Entry<K,V>,java.lang.Long>> removecmd, boolean touchonread, boolean touchonwrite, boolean passive, IDelayRunner timer, boolean sync)
public int size()
public boolean isEmpty()
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
key
- key whose presence in this map is to be tested.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the key is
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<K,V>
value
- value whose presence in this map is to be tested.java.lang.ClassCastException
- if the value is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the value is
public V get(java.lang.Object key)
get
in interface java.util.Map<K,V>
key
- key whose associated collection is to be returned.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- key is
containsKey(Object)
public V put(K key, V value)
m.containsKey(k)
would return
put
in interface java.util.Map<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.java.lang.UnsupportedOperationException
- if the
java.lang.ClassCastException
- if the class of the specified key or value
prevents it from being stored in this map.java.lang.IllegalArgumentException
- if some aspect of this key or value
prevents it from being stored in this map.java.lang.NullPointerException
- this map does not permit
public void putAll(java.util.Map<? extends K,? extends V> t)
put(k, v)
on this map once
for each mapping from key
putAll
in interface java.util.Map<K,V>
t
- Mappings to be stored in this map.java.lang.UnsupportedOperationException
- if the
java.lang.ClassCastException
- if the class of a key or value in the
specified map prevents it from being stored in this map.java.lang.IllegalArgumentException
- some aspect of a key or value in the
specified map prevents it from being stored in this map.java.lang.NullPointerException
- the specified map is
public void clear()
public java.util.Set<K> keySet()
keySet
in interface java.util.Map<K,V>
public java.util.Collection<V> values()
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<K,V>
equals
in class java.lang.Object
o
- object to be compared for equality with this map.public int hashCode()
hashCode
in interface java.util.Map<K,V>
hashCode
in class java.lang.Object
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
public java.lang.String toString()
toString
in class java.lang.Object
public V remove(java.lang.Object key)
remove
in interface java.util.Map<K,V>
key
- key whose mapping is to be removed from the map.java.lang.ClassCastException
- if the key is of an inappropriate type for
this map (optional).java.lang.NullPointerException
- if the key is
public void touch(K key)
entry
- The entry.public void checkStale()
public static void main(java.lang.String[] args)