DefaultNodeCursor.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 * Guido Tack <tack@gecode.org> 00006 * 00007 * Contributing authors: 00008 * Mikael Lagerkvist <lagerkvist@gecode.org> 00009 * 00010 * Copyright: 00011 * Marco Kuhlmann, 2005 00012 * Guido Tack, 2006 00013 * 00014 * Last modified: 00015 * $Date: 2006-10-26 11:31:58 +0200 (Thu, 26 Oct 2006) $ by $Author: tack $ 00016 * $Revision: 3796 $ 00017 * 00018 * This file is part of Gecode, the generic constraint 00019 * development environment: 00020 * http://www.gecode.org 00021 * 00022 * See the file "LICENSE" for information on usage and 00023 * redistribution of this file, and for a 00024 * DISCLAIMER OF ALL WARRANTIES. 00025 * 00026 */ 00027 00028 package org.gecode.gist; 00029 00030 abstract public class DefaultNodeCursor implements NodeCursorInterface { 00031 00032 private Node startNode; 00033 private Node node; 00034 00035 public DefaultNodeCursor(Node theNode) { 00036 this.startNode = theNode; 00037 this.node = theNode; 00038 } 00039 00040 public Node getCurrentNode() { 00041 return node; 00042 } 00043 00044 public boolean mayMoveUpwards() { 00045 return (node != startNode && ! node.isRoot()); 00046 } 00047 00048 public void moveUpwards() { 00049 node = node.getParent(); 00050 } 00051 00052 public boolean mayMoveDownwards() { 00053 return (node.getNumberOfChildren() > 0); 00054 } 00055 00056 public void moveDownwards() { 00057 node = node.getFirstChild(); 00058 } 00059 00060 public boolean mayMoveSidewards() { 00061 return (! node.isLastChild()); 00062 } 00063 00064 public void moveSidewards() { 00065 node = node.getNextSibling(); 00066 } 00067 00068 abstract public void processCurrentNode(); 00069 00070 }
