public class SimpleBacktrackableManager extends Object implements BacktrackableManager
Modifier and Type | Field and Description |
---|---|
int |
currentLevel
It specifies the current level which is active in the manager.
|
boolean |
currentLevelMax
It specifies if for the current level we have reached the cutoff value.
|
Backtrackable[] |
objects
It stores objects which change has to be restored upon backtracking.
|
boolean |
trailContainsAllChanges
It specifies if for the current level the all changes are already
stored in the trail.
|
Constructor and Description |
---|
SimpleBacktrackableManager(Backtrackable[] vars,
int noOfObjects)
It constructs a trail manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addChanged(int index)
It allows to inform the manager that a given item with id (index) has changed at given level.
|
int |
getLevel()
It returns the current level at which the changes are being registered.
|
boolean |
isRecognizedAsChanged(int index)
It allows for easy testing if a given object is considered by
the manager as the object which has changed and needs being
informed about backtracking.
|
void |
removeLevel(int removedLevel)
It allows to inform all objects which have changed at removedLevel
that the backtracking from that level has occurred.
|
void |
setLevel(int level)
It specifies the level which should become the active one in the manager.
|
void |
setSize(int size)
It specifies how many objects within objects array are being actually
managed.
|
String |
toString() |
void |
update(Backtrackable[] objects,
int noOfObjects)
It updates the manager with new array of objects to manage and new number of them.
|
public int currentLevel
public Backtrackable[] objects
public boolean trailContainsAllChanges
public boolean currentLevelMax
public SimpleBacktrackableManager(Backtrackable[] vars, int noOfObjects)
noOfObjects
- it specifies number of objects being managed.vars
- it specifies the list of objects being managed.public void addChanged(int index)
addChanged
in interface BacktrackableManager
index
- it specifies the index of the object which has changed.public void setLevel(int level)
setLevel
in interface BacktrackableManager
level
- the active level at which the changes will be recorded.public void removeLevel(int removedLevel)
removeLevel
in interface BacktrackableManager
removedLevel
- it specifies the level which is being removed.public void setSize(int size)
setSize
in interface BacktrackableManager
size
- the number of objects in the array.public boolean isRecognizedAsChanged(int index)
isRecognizedAsChanged
in interface BacktrackableManager
index
- the position of the object which status is in question.public int getLevel()
BacktrackableManager
getLevel
in interface BacktrackableManager
public void update(Backtrackable[] objects, int noOfObjects)
BacktrackableManager
update
in interface BacktrackableManager
objects
- a new array of objectsnoOfObjects
- number of objects in the new array to be taken care of.Copyright © 2022. All rights reserved.