DFS.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package org.gecode.gist;
00029
00030 import java.util.*;
00031
00032 public class DFS implements SearchEngineInterface {
00033 private Stack<SpaceNode> stack;
00034
00035 public DFS() {
00036 stack = new Stack<SpaceNode>();
00037 }
00038
00039 public void setup(SpaceNode root) {
00040 stack.clear();
00041 stack.push(root);
00042 }
00043
00044 public boolean step() {
00045 if (stack.empty())
00046 return true;
00047 SpaceNode node = stack.pop();
00048 Iterator childrenIterator = node.reversedChildrenIterator();
00049 while (childrenIterator.hasNext()) {
00050 SpaceNode nextChild = (SpaceNode) childrenIterator.next();
00051 if (nextChild.isOpen())
00052 stack.push(nextChild);
00053 }
00054 return stack.empty();
00055 }
00056
00057 }