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

public class TimeStamp<T> extends 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final boolean
     
    (package private) int
     
    int
     
    int[]
     
    (package private) Store
     
    T[]
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    (package private) final void
    addLast(T input, int level)
     
    void
    ensureCapacity(int minCapacity)
    Specify least number of different values to be used by Timestamp.
    (package private) final int
     
    final T
     
    void
    removeLevel(int level)
    The function removes the level specified by the stamp.
    final int
    It returns the value of the most recent stamp used within that timestamp.
     
    void
    update(T val)
    It updates the value of the timestamp with the provided value.
    final T
    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

      public transient T[] values
  • Constructor Details

    • 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 Details

    • 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 String toString()
      Overrides:
      toString in class 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.