JaCoP.core
Class TimeStamp<T>

java.lang.Object
  extended by JaCoP.core.TimeStamp<T>
Type Parameters:
T - a class being stored at different time stamps.

public class TimeStamp<T>
extends java.lang.Object

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:
3.1
Author:
Radoslaw Szymanek and Krzysztof Kuchcinski

Constructor Summary
TimeStamp(Store store, T input)
          The constructor.
 
Method Summary
 void ensureCapacity(int minCapacity)
          Specify least number of different values to be used by Timestamp.
 T previousValue()
           
 void remove(int stamp)
          The function removes the level specified by the stamp.
 int stamp()
          It returns the value of the most recent stamp used within that timestamp.
 java.lang.String toString()
           
 void update(T val)
          It updates the value of the timestamp with the provided value.
 T value()
          It returns the most recent value of the timestamp.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeStamp

public TimeStamp(Store store,
                 T input)
The constructor.

Parameters:
store - the store where the timestamp is registered.
input - the value of the stamp to be stored.
Method Detail

ensureCapacity

public void ensureCapacity(int minCapacity)
Specify least number of different values to be used by Timestamp.

Parameters:
minCapacity -

previousValue

public final T previousValue()
Returns:
the previous value according to the stamp.

remove

public void remove(int stamp)
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.

Parameters:
stamp - 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

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public void update(T val)
It updates the value of the timestamp with the provided value.

Parameters:
val - value to which the timestamp needs to be updated.

value

public final T value()
It returns the most recent value of the timestamp.

Returns:
the most recent value of the timestamp.