View Javadoc

1   package cz.cuni.amis.utils.astar;
2   
3   import java.util.Iterator;
4   
5   /**
6    * Clasical iterator for AStarHeap.
7    * 
8    * <p><p>
9    * Use amis-path-finding library instead, see svn://artemis.ms.mff.cuni.cz/pogamut/trunk/project/Utils/AmisPathFinding
10   */
11  @Deprecated
12  public class AStarHeapIterator<NODE> implements Iterator {
13  	
14  	private NODE[] nodes;
15  	private int items;
16  	private int current;
17  	private AStarHeap heap;
18  	
19  	public AStarHeapIterator(NODE[] myNodes, int myItems, AStarHeap<NODE> myHeap){
20  		nodes = myNodes;
21  		items = myItems;
22  		current = 0;
23  		heap = myHeap;
24  	}
25  
26  	public boolean hasNext() {
27  		return (current < items);		
28  	}
29  
30  	public Object next() {
31  		if (current < items){
32  			return nodes[current++];
33  		} else {
34  			return null;
35  		}		
36  	}
37  
38  	public void remove() {
39  		if (current == 0) 
40  			return;
41  		heap.remove(nodes[current-1]);
42  		current = current - 1;
43  		items = items - 1;
44  	}
45  
46  }