choco.mem
Class StoredFloatTrail

java.lang.Object
  extended by choco.mem.StoredFloatTrail
All Implemented Interfaces:
ITrailStorage

public class StoredFloatTrail
extends java.lang.Object
implements ITrailStorage

A backtrackable float variable trail storing past values of all the float variables.


Constructor Summary
StoredFloatTrail(Environment env, int nUpdates, int nWorlds)
          Constructs a trail with predefined size.
 
Method Summary
 int getSize()
          Returns the current size of the stack.
 void resizeWorldCapacity(int newWorldCapacity)
          Resizes the data structure to manage more values.
 void savePreviousState(StoredFloat v, double oldValue, int oldStamp)
          Reacts when a StoredInt is modified: push the former value & timestamp on the stacks.
 void worldCommit()
          Commits a world: merging it with the previous one.
 void worldPop()
          Moving down to the previous world.
 void worldPush()
          Moving up to the next world.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoredFloatTrail

public StoredFloatTrail(Environment env,
                        int nUpdates,
                        int nWorlds)
Constructs a trail with predefined size.

Parameters:
env - the environment responsible of managing worlds
nUpdates - maximal number of updates that will be stored
nWorlds - maximal number of worlds that will be stored
Method Detail

worldPush

public void worldPush()
Moving up to the next world.

Specified by:
worldPush in interface ITrailStorage

worldPop

public void worldPop()
Moving down to the previous world.

Specified by:
worldPop in interface ITrailStorage

getSize

public int getSize()
Returns the current size of the stack.

Specified by:
getSize in interface ITrailStorage
Returns:
the size of the trail

worldCommit

public void worldCommit()
Commits a world: merging it with the previous one.

Specified by:
worldCommit in interface ITrailStorage

savePreviousState

public void savePreviousState(StoredFloat v,
                              double oldValue,
                              int oldStamp)
Reacts when a StoredInt is modified: push the former value & timestamp on the stacks.

Parameters:
v - tha variable to store the value
oldValue - the previous value to store
oldStamp - the previous stamp value (to know when this old value will be updated again when backtracking)

resizeWorldCapacity

public void resizeWorldCapacity(int newWorldCapacity)
Resizes the data structure to manage more values.

Specified by:
resizeWorldCapacity in interface ITrailStorage
Parameters:
newWorldCapacity - the new capacity requested for world management