Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.fh.stud.p3;
- import de.fh.stud.p1.Knoten;
- public class DFS_List extends Search_List {
- int fringeDepth = 10;
- int currentDepth = 0;
- public DFS_List(int fringeDepth) {
- this.fringeDepth = fringeDepth;
- }
- @Override
- public StackTuple get() {
- StackTuple fetched = tupleStorage.removeFirst();
- if(currentDepth > 0){
- //The Node is from a different depth if the previous != lastFetched.previous
- if(!lastFetched.getNode().previous.equals(fetched.getNode().previous)){
- //Then all Nodes in the depth are processed
- currentDepth--;
- }
- }
- lastFetched = fetched;
- return fetched;
- }
- @Override
- public void add(Knoten node) {
- if(currentDepth < fringeDepth){
- tupleStorage.add(0, new StackTuple(node, 0));
- //The Node is from a different depth if the previous != lastFetched.previous
- if(lastFetched != null && lastFetched.getNode().equals(node.previous) ) {
- currentDepth++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement