I have three set of three sets and I want to do this algorithmically:
For the first treeset in treesets do till all done:
dosomething(treeset)
if done(treeset) {
remove treeset from treesets
sort treesets
// now the next treeset to dosomething will be the first treeset in treesets since we change the sorting but I want to make sure the sorting is applied there
}
}
What is the best way of doing that? A very simple example:
treeset1
treeset2
treeset3
treeset4
Go to treeset1, do something on it, if done, then remove treeset1, sort, next element will become treeset4 (originally was treeset2), now do something on treeset4, not done, do not remove treesert4, sort again, the next is treeset3, do something, done, treeset3 done, sort again, again treeset4 comes up in sortting, do something on treeset4 .....
What is the best practice? I have the sorting function that works. The algorithm will stop once I reach the last element and could not remove any more element.
I figured it out to do it with Iterator. After each loop, I resort the iterator and call for next(). It solved my problem.