Package jadex.collection
Class PassiveLeaseTimeSet<E>
java.lang.Object
jadex.collection.PassiveLeaseTimeSet<E>
- All Implemented Interfaces:
ILeaseTimeSet<E>,Iterable<E>,Collection<E>
Collection that remove elements after a lease time on trigger.
This class is not synchronized.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PriorityQueue<E> The entries.protected longThe leasetime.static final longConstant for no leasetime.The cleaner.The timestamps.static final longConstant for unset leasetime (use global default otherwise no leasetime). -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new lease time handling object.PassiveLeaseTimeSet(long leasetime) Create a new lease time handling object.PassiveLeaseTimeSet(long leasetime, Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a new lease time handling object.PassiveLeaseTimeSet(Consumer<jadex.common.Tuple2<E, Long>> removecmd) Create a new lease time handling object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanAdd a new entry.booleanaddAll(Collection<? extends E> c) voidStart removing discovered entries.voidclear()booleanbooleancontainsAll(Collection<?> c) booleanprotected longGet the current time.protected LonggetExpirationTime(long leasetime) Get the expiration time.longGet the leasetime.inthashCode()Get the hashcode.booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) voidsetRemoveCommand(Consumer<jadex.common.Tuple2<E, Long>> cmd) Set the remove cmd.intsize()Object[]toArray()<T> T[]toArray(T[] a) voidUpdate the timestamp of e.voidUpdate the timestamp of e.booleanAdd a new entry or update an existing entry.booleanAdd a new entry or update an existing entry.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
NONE
public static final long NONEConstant for no leasetime.- See Also:
-
UNSET
public static final long UNSETConstant for unset leasetime (use global default otherwise no leasetime).- See Also:
-
entries
The entries. -
times
The timestamps. -
leasetime
protected long leasetimeThe leasetime. -
removecmd
The cleaner.
-
-
Constructor Details
-
PassiveLeaseTimeSet
public PassiveLeaseTimeSet()Create a new lease time handling object. -
PassiveLeaseTimeSet
public PassiveLeaseTimeSet(long leasetime) Create a new lease time handling object. -
PassiveLeaseTimeSet
Create a new lease time handling object. -
PassiveLeaseTimeSet
Create a new lease time handling object.
-
-
Method Details
-
setRemoveCommand
Set the remove cmd.- Specified by:
setRemoveCommandin interfaceILeaseTimeSet<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E>
-
add
- Specified by:
addin interfaceCollection<E>
-
add
Description copied from interface:ILeaseTimeSetAdd a new entry.- Specified by:
addin interfaceILeaseTimeSet<E>- Parameters:
e- The entry.leasetime- The leasetime.- Returns:
- True, if new entry.
-
remove
- Specified by:
removein interfaceCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>
-
equals
- Specified by:
equalsin interfaceCollection<E>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()Get the hashcode.- Specified by:
hashCodein interfaceCollection<E>- Overrides:
hashCodein classObject
-
update
Add a new entry or update an existing entry.- Specified by:
updatein interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.- Returns:
- True, if new entry.
-
update
Add a new entry or update an existing entry.- Specified by:
updatein interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.- Returns:
- True, if new entry.
-
touch
Update the timestamp of e.- Specified by:
touchin interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.
-
touch
Update the timestamp of e.- Specified by:
touchin interfaceILeaseTimeSet<E>- Parameters:
entry- The entry.
-
getExpirationTime
Get the expiration time.- Parameters:
leasetime-- Returns:
-
checkStale
public void checkStale()Start removing discovered entries. -
getClockTime
protected long getClockTime()Get the current time. -
getLeaseTime
public long getLeaseTime()Get the leasetime.
-