Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. package de.fh.stud.p3;
  2.  
  3. import de.fh.stud.p1.Knoten;
  4.  
  5. public class DFS_List extends Search_List {
  6.  
  7. int fringeDepth = 10;
  8. int currentDepth = 0;
  9.  
  10.  
  11. public DFS_List(int fringeDepth) {
  12. this.fringeDepth = fringeDepth;
  13. }
  14.  
  15.  
  16.  
  17. @Override
  18. public StackTuple get() {
  19. StackTuple fetched = tupleStorage.removeFirst();
  20.  
  21. if(currentDepth > 0){
  22.  
  23. //The Node is from a different depth if the previous != lastFetched.previous
  24. if(!lastFetched.getNode().previous.equals(fetched.getNode().previous)){
  25. //Then all Nodes in the depth are processed
  26. currentDepth--;
  27. }
  28. }
  29.  
  30. lastFetched = fetched;
  31.  
  32. return fetched;
  33. }
  34.  
  35.  
  36.  
  37. @Override
  38. public void add(Knoten node) {
  39.  
  40. if(currentDepth < fringeDepth){
  41.  
  42. tupleStorage.add(0, new StackTuple(node, 0));
  43.  
  44. //The Node is from a different depth if the previous != lastFetched.previous
  45. if(lastFetched != null && lastFetched.getNode().equals(node.previous) ) {
  46. currentDepth++;
  47. }
  48. }
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement