Generated on Thu Nov 2 14:49:35 2006 for Gecode/J by doxygen 1.5.0

PostOrderNodeVisitor.java

Go to the documentation of this file.
00001 /* -*- indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Marco Kuhlmann <kuhlmann@ps.uni-sb.de>
00005  *
00006  *  Copyright:
00007  *     Marco Kuhlmann, 2005
00008  *
00009  *  Last modified:
00010  *     $Date: 2006-10-26 11:31:58 +0200 (Thu, 26 Oct 2006) $ by $Author: tack $
00011  *     $Revision: 3796 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  See the file "LICENSE" for information on usage and
00018  *  redistribution of this file, and for a
00019  *     DISCLAIMER OF ALL WARRANTIES.
00020  *
00021  */
00022 
00023 package org.gecode.gist;
00024 
00025 
00026 public class PostOrderNodeVisitor extends DefaultNodeVisitor {
00027     
00028     public PostOrderNodeVisitor(NodeCursorInterface theCursor) {
00029         super(theCursor);
00030         moveToLeaf();
00031     }
00032     
00033     private void moveToLeaf() {
00034         while (cursor.mayMoveDownwards()) {
00035             cursor.moveDownwards();
00036         }
00037     }
00038     
00039     public boolean next() {
00040         cursor.processCurrentNode();
00041         if (cursor.mayMoveSidewards()) {
00042             cursor.moveSidewards();
00043             moveToLeaf();
00044         } else if (cursor.mayMoveUpwards()) {
00045             cursor.moveUpwards();
00046         } else {
00047             cursor = null;
00048         }
00049         return (cursor != null);
00050     }
00051 
00052 }