Class SimpleSolutionManager
java.lang.Object
fr.inria.rules.integraal.query_evaluation.conjunction.backtrack.SimpleSolutionManager
- All Implemented Interfaces:
SolutionManager
SimpleSolutionManager
Lean, allocation‑friendly implementation of SolutionManager.
Key points:
- In‑place fusion via
mergeInPlace– zero temporary objects on the hot path. - For each depth we keep only: the candidate spliterator and truly new variables (those not bound at any shallower level) so rollback work is minimal.
- A global
boundVariablesset tracks which variables are already present to compute the fresh set in O(n).
- Author:
- Guillaume Perution-Kihli
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a solution manager with an empty initial substitution.SimpleSolutionManager(Substitution prefix) Creates a solution manager with the supplied initial substitution. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int level, Spliterator<Substitution> substitutions, Collection<Variable> newVariables) Register the spliterator that will supply substitutions forleveltogether with the
list of variables that those substitutions can bind for the first time.Returns a stable snapshot of the current solution.deepCopy()Creates an independent copy of this solution manager.Returns the substitution that is currently valid at all explored levels.getSpliterator(int level) Returns the spliterator registered for a level.booleannext(int level) Advance the iterator atlevelso the next candidate substitution (if any) is merged into the global solution.voidpruneOtherIterators(int level) Prunes every stored iterator except the selected level.voidreplaceSpliterator(int level, Spliterator<Substitution> newSpliterator) Replaces the spliterator registered for a level.toString()
-
Constructor Details
-
SimpleSolutionManager
public SimpleSolutionManager()Creates a solution manager with an empty initial substitution. -
SimpleSolutionManager
Creates a solution manager with the supplied initial substitution.- Parameters:
prefix- the substitution that must always remain in the current solution
-
-
Method Details
-
getCurrentSolution
Description copied from interface:SolutionManagerReturns the substitution that is currently valid at all explored levels.Live view: subsequent calls to
SolutionManager.next(int)may mutate and/or invalidate the content. Clone it withSolutionManager.copyCurrentSolution()if you need to keep a stable version.- Specified by:
getCurrentSolutionin interfaceSolutionManager- Returns:
- the current live substitution
-
copyCurrentSolution
Description copied from interface:SolutionManagerReturns a stable snapshot of the current solution.- Specified by:
copyCurrentSolutionin interfaceSolutionManager- Returns:
- a defensive copy of the current solution (safe to keep).
-
next
public boolean next(int level) Description copied from interface:SolutionManagerAdvance the iterator atlevelso the next candidate substitution (if any) is merged into the global solution.- Specified by:
nextin interfaceSolutionManager- Parameters:
level- depth in the search tree (0‑based)- Returns:
trueif a compatible substitution exists,falseotherwise.
-
add
public void add(int level, Spliterator<Substitution> substitutions, Collection<Variable> newVariables) Description copied from interface:SolutionManagerRegister the spliterator that will supply substitutions forleveltogether with the
list of variables that those substitutions can bind for the first time.- Specified by:
addin interfaceSolutionManager- Parameters:
level- depth in the search tree (0-based)substitutions- the substitutions available at that levelnewVariables- the variables that may become bound at that level
-
getSpliterator
Description copied from interface:SolutionManagerReturns the spliterator registered for a level.- Specified by:
getSpliteratorin interfaceSolutionManager- Parameters:
level- depth in the search tree (0-based)- Returns:
- the spliterator associated with
level, ornull.
-
replaceSpliterator
Description copied from interface:SolutionManagerReplaces the spliterator registered for a level. Replace the spliterator stored forlevel.- Specified by:
replaceSpliteratorin interfaceSolutionManager- Parameters:
level- depth in the search tree (0-based)newSpliterator- the replacement spliterator
-
pruneOtherIterators
public void pruneOtherIterators(int level) Description copied from interface:SolutionManagerPrunes every stored iterator except the selected level. Remove (or empty) every level that is not equal tolevel.- Specified by:
pruneOtherIteratorsin interfaceSolutionManager- Parameters:
level- the level to keep
-
deepCopy
Description copied from interface:SolutionManagerCreates an independent copy of this solution manager.- Specified by:
deepCopyin interfaceSolutionManager- Returns:
- an independent copy of this manager so that another branch can evolve in parallel without interference.
-
toString
-