Class TimeStamp<T>

  • Type Parameters:
    T - a class being stored at different time stamps.
    All Implemented Interfaces:
    Stateful

    public class TimeStamp<T>
    extends java.lang.Object
    implements 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
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeStamp​(Store store, T input)
      The constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void addLast​(T input, int level)  
      void ensureCapacity​(int minCapacity)
      Specify least number of different values to be used by Timestamp.
      (package private) int index()  
      T previousValue()  
      void removeLevel​(int level)
      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

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • index

        int index
      • pointer4Last

        public int pointer4Last
      • stamps

        public transient int[] stamps
      • values

        public transient T[] values
    • 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

      • addLast

        final void addLast​(T input,
                           int level)
      • 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

        public final T 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 interface Stateful
        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

        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.