Create an Iterator from your queue:
[url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#iterator()]http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#iterator()[/url]
Create a new queue:
[url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#PriorityQueue()]http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#PriorityQueue()[/url]
And clone each element in your iterator and store it in your new queue:
http://java.sun.com/docs/books/tutorial/java/IandI/objectclass.html
Thanks, the code is here
private void excuteTableau(Branch branch){
if(this.getToDoQueue().isEmpty()){
this.getAllBranches().add(branch);
return;
}
// Get an Entry from the top of the queue
ToDoEntry toDoEntry = (ToDoEntry) this.getToDoQueue().peek();
if(toDoEntry.isActive()){
toDoEntry.expandRules();
ArrayList possibleChoiceList = toDoEntry.getPossibleExpansions();
if(possibleChoiceList.size()==1){
Set possibleChoice_ = (Set)(possibleChoiceList.get(0));
this.getToDoQueue().remove(toDoEntry);
branch.getBranchElems().addAll(possibleChoice_);
Iterator iterator = possibleChoice_.iterator();
while(iterator.hasNext()){
ATermAppl a = (ATermAppl)iterator.next();
this.addToDoEntry(a, branch);
}
excuteTableau(branch);
}
else{
this.getToDoQueue().remove(toDoEntry);
// Deep Copy the queue after the removement!!
// ..............
for(int i=0; i<possibleChoiceList.size();i++ ){
Set possibleChoice_ = (Set)(possibleChoiceList.get(i));
Branch splittedBranch = new Branch();
splittedBranch.deepCopy(branch);
this.setReferredBranchForQueue(splittedBranch);
splittedBranch.getBranchElems().addAll(possibleChoice_);
Iterator iterator = possibleChoice_.iterator();
while(iterator.hasNext()){
ATermAppl a = (ATermAppl)iterator.next();
this.addToDoEntry(a, splittedBranch);
}
excuteTableau(splittedBranch);
}
// Resort the queue goes here
// ....................
this.getToDoQueue().add(toDoEntry);
}
}
else{
excuteTableau(branch);
}
}>