Package org.jacop.core
Class TimeStamp<T>
java.lang.Object
org.jacop.core.TimeStamp<T>
- Type Parameters:
T
- a class being stored at different time stamps.
- All Implemented Interfaces:
Stateful
This class provides mutable variable functionality. The variable value
depends on the store level. Each value is time stamped with different store
level. This class lets you avoid recomputation every time a solver
backtracks. It will simply use the value with older time stamp. It is
appropriate for objects which do not share data across store levels. If you
have objects which share data across store levels than you need to make your
own implementation of mutable variable using MutableVar interface.
It will (it has to) store the same object at different levels as users of the timestamp may ask for the level at which the timestamp was recently updated.
- Version:
- 4.8
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final void
void
ensureCapacity
(int minCapacity) Specify least number of different values to be used by Timestamp.(package private) final int
index()
final T
void
removeLevel
(int level) The function removes the level specified by the stamp.final int
stamp()
It returns the value of the most recent stamp used within that timestamp.toString()
void
It updates the value of the timestamp with the provided value.final T
value()
It returns the most recent value of the timestamp.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jacop.api.Stateful
isStateful
-
Field Details
-
debug
static final boolean debug- See Also:
-
index
int index -
pointer4Last
public int pointer4Last -
stamps
public transient int[] stamps -
store
Store store -
values
-
-
Constructor Details
-
TimeStamp
The constructor.- Parameters:
store
- the store where the timestamp is registered.input
- the value of the stamp to be stored.
-
-
Method Details
-
addLast
-
ensureCapacity
public void ensureCapacity(int minCapacity) Specify least number of different values to be used by Timestamp.- Parameters:
minCapacity
- capacity that will be ensured
-
index
final int index() -
previousValue
- Returns:
- the previous value according to the stamp.
-
removeLevel
public void removeLevel(int level) The function removes the level specified by the stamp. It assumes that it removes all the levels from the most recent until the level (inclusive) specified by the parameter.- Specified by:
removeLevel
in interfaceStateful
- Parameters:
level
- the number of the level.
-
stamp
public final int stamp()It returns the value of the most recent stamp used within that timestamp.- Returns:
- the stamp value.
-
toString
-
update
It updates the value of the timestamp with the provided value.- Parameters:
val
- value to which the timestamp needs to be updated.
-
value
It returns the most recent value of the timestamp.- Returns:
- the most recent value of the timestamp.
-