What i would like to do is the following.
(Not sure if this question should go to StackOverflow, or here)
Consider a datastructure like this:
interface IAction {
IAction[] afterActions()
IAction[] beforeActions()
void execute()
}
What I would like to do is execute() a IAction collection, in the manner, that
- All
beforeActions()are executed before the supplier of thebeforeActions()calls result. - All
afterActions()are executed after the supplier of theafterActions()calls result. - Be able to detect "cyclic dependencies", so if one should execute before and after another, or after itself, or after another action, that on any path should execute before, etc.
In other worlds I would like to "sort" these actions in an executable order.
I would like to get only an explanation on how I should (could) do this, I don't expect anyone to implement anything for me (notice, that I intentionally didn't specify a language).
If you know about any generic algorithm for this purpose, that you think is suitable for the problem, please feel free to share with a minimal explanation, on how you would translate it to this problem
Aucun commentaire:
Enregistrer un commentaire